]> git.phdru.name Git - dotfiles.git/commitdiff
.bash_prompt: change colors and styles
authorOleg Broytman <phd@phdru.name>
Wed, 24 Feb 2016 10:37:48 +0000 (13:37 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 24 Feb 2016 10:37:48 +0000 (13:37 +0300)
.bash_prompt

index 1d4f24535cddfce7d5297b73ca309a4728e0ecad..6284416032fca32b1292d364d11c7abb459e811d 100644 (file)
@@ -136,34 +136,52 @@ set_prompts() {
         dim_yellow="\e[1;33m"
     fi
 
-    # build the prompt
+    charStyle="$reset$bold$black"
+    gitStyle="\[$white\]on \[$magenta\]"
+    case "$BACKGROUND" in
+       DARK|dark)
+          hostStyle="$reset$cyan"
+       ;;
+       LIGHT|light)
+          hostStyle="$reset$blue"
+       ;;
+    esac
+    wdirStyle="$reset$green"
+
 
     # logged in as root
     if [[ "$USER" == "root" ]]; then
-        userStyle="\[$bold$red\]"
+        userStyle="$bold$red"
     else
-        userStyle="\[$orange\]"
+        userStyle="$orange"
     fi
 
-    # connected via ssh
-    if [[ "$SSH_TTY" ]]; then
-        hostStyle="\[$bold$red\]"
-    else
-        hostStyle="\[$yellow\]"
-    fi
-
-    # set the terminal title to the current working directory
-    PS1="\[\033]0;\w\007\]"
-
-    PS1+="\n" # newline
+    # build the prompt
+    # display the user, host and current working directory in the terminal title
+    case "$TERM" in
+       *rxvt*|screen*|*term*|vt100)
+          PS1="\[\033]0;\u@\h:\w\007\]"
+          case "$TERM" in
+             screen*)
+                PS1+"\[\033k\u@\h:\w\033\\\]" # Set screen/tmux caption
+             ;;
+          esac
+       ;;
+
+       *)
+          PS1=""
+       ;;
+    esac
+
+    #PS1+="\n" # newline
     PS1+="\[$userStyle\]\u" # username
-    PS1+="\[$reset$white\]@"
-    PS1+="\[$hostStyle\]\h" # host
-    PS1+="\[$reset$white\]: "
-    PS1+="\[$green\]\w" # working directory
-    PS1+="\$(prompt_git \"$white on $cyan\")" # git repository details
-    PS1+="\n"
-    PS1+="\[$reset$white\]\$ \[$reset\]" # $ (and reset color)
+    PS1+="\[$charStyle\]@"
+    PS1+="\[$hostStyle\]\h " # host
+    #PS1+="\[$charStyle\]: "
+    PS1+="\[$wdirStyle\]\W " # working directory
+    PS1+="\$(prompt_git \"$gitStyle\")" # git repository details
+    #PS1+="\n"
+    PS1+="\[$charStyle\]\$ \[$reset\]" # $ (and reset color)
 
     export PS1
 }