Advertisement
jms1

bash prompt options

Dec 23rd, 2017
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1.     ########################################
  2.     # set up prompt
  3.  
  4.     if [ "$UID" = "0" ]
  5.     then
  6.         pc='1;37;41'    # root: bright white on red
  7.     elif [ -n "${SSH_CLIENT:-}" ]
  8.     then
  9.         pc='1;33;44'    # non-local: is yellow on blue
  10.     else
  11.         pc='1;30;42'    # local: bright black on green
  12.     fi
  13.  
  14.     PROMPT_TOP_STAY=false
  15.     PROMPT_TOP_ONLY=false
  16.  
  17.     if $PROMPT_TOP_STAY
  18.     then
  19.         p1='\[\e[s\e[H\e[0;'
  20.         p2='m\e[K(\u@\h) \# \w\e[0m\e[2r\e[u\]\$ '
  21.         PS1="$p1$pc$p2"
  22.         unset p1 p2 pc
  23.     elif $PROMPT_TOP_ONLY
  24.     then
  25.         p1='\[\e[s\e[H\e[0;'
  26.         p2='m\e[K(\u@\h) \# \w\e[0m\e[u\]\$ '
  27.         PS1="$p1$pc$p2"
  28.         unset p1 p2 pc
  29.     else
  30.         p1='\[\e[0;'
  31.         p2='m\](\u@\h) \# \w \$\[\e[0m\] '
  32.         PS1="$p1$pc$p2"
  33.         unset p1 p2 pc
  34.     fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement