X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=blobdiff_plain;f=.bash_prompt;h=6126ef25240e8358dbb2ef4f25f09c420072f18c;hp=1d4f24535cddfce7d5297b73ca309a4728e0ecad;hb=01750040116e8b50ca033c9b44348027a8edba5b;hpb=2d247f3edd73ddd6e758b52b2d739c0a20227a34 diff --git a/.bash_prompt b/.bash_prompt index 1d4f245..6126ef2 100644 --- a/.bash_prompt +++ b/.bash_prompt @@ -1,7 +1,8 @@ #!/bin/bash # bash_prompt; adapted from -# https://github.com/necolas/dotfiles/blob/master/shell/bash_prompt +# https://github.com/necolas/dotfiles/blob/master/shell/bash_prompt and +# http://vitus-wagner.livejournal.com/1176589.html?thread=40146189#t40146189 prompt_git() { local s="" @@ -136,34 +137,53 @@ 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+='`erco=$?; [ $erco == 0 ] && echo -n ":)" || echo -n '"\"\[$red\]:(\[$reset\] $\""'?=$erco` ' + PS1+="\$(prompt_git \"$gitStyle\")" # git repository details + #PS1+="\n" + PS1+="\[$charStyle\]\$ \[$reset\]" # $ (and reset color) export PS1 }