Welcome to Centmin Mod Community
Become a Member

Server Name

Discussion in 'Feature Requests & Suggestions' started by Jimmy, Feb 1, 2017.

  1. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Would it be possible to have the server name listed under the Centmin Mod Menu heading?

    --------------------------------------------------------
    Centmin Mod Menu 123.09beta01 centminmod.com
    Server: sever1.domainname.com
    --------------------------------------------------------

    I might have 2 or 3 terminal windows open at the same time. If I am looking at the menu, it would be nice to make sure I'm on the right server. I know it's other places, but a few times, when I was tired, I almost did something to the wrong server. Having it in the menu title would be another safeguard against doing something on the wrong server... for me at least.

    Just a suggestion. :)
     
    • Like Like x 1
  2. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    not in the menu maybe someone outside of it ?

    fyi, if you have unique hostnames, the command prompt will be able to differentiate the servers too ;) i.e. instead of server1.hostname.com, use webhostname-location-1.hostname.com

    so instead of

    [root@server1]#

    would be

    [root@webhostname-location-1]#
     
    Last edited: Feb 1, 2017
  3. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Where ever you feel it is best. Just something so that when I have 2 menus side by side, I know which one is which. :)

    Thought having it in the menu would good. Not sure where else it could go.
     
  4. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Yea, I often look at that because my naming convention is server1, server2, etc. It's also at the top of the terminal window.

    Mainly when I get tired and have two menus open at the same time, I've a few times, almost did the wrong thing because I was focused on the CMM menu vs. double checking which server / window.
     
  5. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    Guess it's just habit.. I routinely have up to 10-30 server SSH windows open at a time, never had any probs :)
     
  6. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Just wanted to make the suggestion. It's up to you if you want to add it or not. :)
     
    • Like Like x 2
  7. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    Hmmm worse case GitLab employee ran rm -rf on production LOL

    Gitlab employee accidentally deletes live data
     
    • Funny Funny x 1
  8. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    --------------------------------------------------------
    Centmin Mod Menu 123.09beta01 centminmod.com
    Server: sever1.domainname.com
    --------------------------------------------------------

    ;)
     
  9. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    changing command prompt BASH Shell: Change The Color of My Shell Prompt Under Linux or UNIX

    i.e. full hostname and cyan blue
    Code (Text):
    PS1="\e[0;36m[\u@\H \w]\\$ \e[m "


    full hostname and lighter cyan blue
    Code (Text):
    PS1="\e[1;36m[\u@\H \w]\\$ \e[m "


    hour:min, full hostname + lighter cyan blue
    Code (Text):
    PS1="\e[1;36m[\$(date +%H:%M)][\u@\H \w]\\$ \e[m "

    or
    Code (Text):
    PS1="\e[1;36m[\A][\u@\H \w]\\$ \e[m " 


    hour:min, full hostname + lighter cyan blue + black background (How to Customize your Bash Prompt on a Linux VPS | DigitalOcean)
    Code (Text):
    PS1="\e[40;1;36m[\A][\u@\H \w]\\$ \e[m " 


    example

    upload_2017-2-2_3-29-36.png
     
    Last edited: Feb 2, 2017
    • Informative Informative x 2
  10. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Interesting! I'll have to check that out. @eva2000 you're loaded with interesting tidbits! :)
     
    • Like Like x 1
  11. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    Yes thinking of making the last one the default in Centmin Mod 123.09beta01

    Code (Text):
    PS1="\e[40;1;36m[\A][\u@\H \w]\\$ \e[m " 


    black terminals

    upload_2017-2-2_3-30-11.png

    white terminals

    upload_2017-2-2_3-37-22.png

    or with white text on black background
    Code (Text):
    PS1="\e[40;1;37m[\A][\u@\H \w]\\$ \e[m "
    


    upload_2017-2-2_3-45-22.png

    clear enough for folks working with multiple SSH windows simultaneously :)

    or leave colours out of it and use

    Code (Text):
    PS1="[\u@\H \w]\\$ "
    
     
    Last edited: Feb 2, 2017
    • Like Like x 1
  12. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
  13. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Looks good! Should make things easier. Though, I'm thinking about using the colors too, because there is no mistaking colors.... unless you're color blind, which I'm not. ;)
     
  14. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    yeah i left out colours as folks maybe have custom SSH client/terminal colour schemes which may get kind of funky :)
     
    • Agree Agree x 1
  15. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Ended up going with this:

    Code:
    PS1="\e[32m[\u@\h \W]\\$ \e[m"
    If someone wants to add the time:

    Code:
    PS1="\e[32m[\A][\u@\h \W]\\$ \e[m"
    I'll change the color (32m) to what I want for each server based on this chart:

    • 30: Black
    • 31: Red
    • 32: Green
    • 33: Yellow
    • 34: Blue
    • 35: Purple
    • 36: Cyan
    • 37: White
     
    Last edited: Feb 2, 2017
    • Like Like x 1
  16. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    but that uses short \h hostname ?
     
  17. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    Don't need the full hostname since I'm using the colors. All my servers are the same domain.
     
  18. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    I see
     
  19. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    7:22 PM
    1.13.x
    MariaDB 10.1.x
    There is no mistaking the colors! I'm loving this!

    Thanks!
     
    • Like Like x 1
  20. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    9:22 AM
    Nginx 1.13.x
    MariaDB 5.5
    also to prevent mishaps, can setup custom alias command for pwd command = list present working directory to also display hostname

    i.e. alias pwdh command
    Code (Text):
    alias pwdh='echo -n "$(hostname) "; pwd'
    

    so when you type pwdh
    Code (Text):
    pwdh
    host1.domain.com /root
    

    Code (Text):
    cd /home/nginx
    pwdh
    host1.domain.com /home/nginx
    


    edit: hmmm pwd won't work in .bashrc heh which needs a bit more tweaking to inset into /root/.bashrc with echo
    Code (Text):
    echo "alias pwdh='echo -n \"\$HOSTNAME\"; echo \" \$PWD\"'" >> /root/.bashrc
    

    after echo append to /root/.bashrc, the entry would appear as
    Code (Text):
    alias pwdh='echo -n "$HOSTNAME"; echo " $PWD"'
    
     
    Last edited: Feb 2, 2017
    • Informative Informative x 1