On 5/24/19 11:29 PM, DJ Lucas via blfs-dev wrote:
Something I've been carrying for a long time to make it obvious that I'm using a remote or screen session. Anyone think this would be a useful addition to the book?

Not really. We have a less detailed but similar version in the section on startup files now. I think it's up to users to customize from that. Besides, I often am remotely logged into 2 or 3 remote systems at once. I like different colors for each. :)

  -- Bruce



# Setup different prompt colors for local/remote and root/non-root users
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
YELLOW="\[\e[1;33m\]"
MAGENTA="\[\e[1;35m\]"
CYAN="\[\e[1;36m\]"

# Set local prompt color
if [[ $EUID == 0 ]] ; then
   if [[ $TERM == "screen" ]] ; then
     PS1="$RED\u [ $NORMAL\w$RED ] (screen)# $NORMAL"
   else
     PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
   fi
else
   if [[ $TERM == "screen" ]] ; then
     PS1="$YELLOW\w [ $NORMAL\w$YELLOW] (screen)\$ $NORMAL"
   else
     PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
   fi
fi

# Set remote prompt
if [[ "$SSH_CLIENT" != "" ]] ; then
   if [[ $EUID == 0 ]] ; then
     if [[ $TERM == "screen" ]] ; then
       PS1="$MAGENTA\u@\h [ $NORMAL\w$MAGENTA ] (screen)# $NORMAL"
     else
       PS1="$MAGENTA\u@\h [ $NORMAL\w$MAGENTA ]# $NORMAL"
     fi
   else
     if [[ $TERM == "screen" ]] ; then
       PS1="$CYAN\u@\h [ $NORMAL\w$CYAN ] (screen)\$ $NORMAL"
     else
       PS1="$CYAN\u@\h [ $NORMAL\w$CYAN ]\$ $NORMAL"
     fi
   fi
fi



--
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to