bash prompt

bash_prompt_command() {
  # How many characters of the $PWD should be kept
  local pwdmaxlen=55
  # Indicate that there has been dir truncation
  local trunc_symbol=".."
  local dir=${PWD##*/}
  pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
  NEW_PWD=${PWD/$HOME/~}
  local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
  if [ ${pwdoffset} -gt "0" ]; then
   NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
    NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
  fi
}
 
bash_prompt() {
  if [ -n "$PS1" ]; then
    PS1="$XTITLE""\033[01;32m\][\!][\u@]\[\033[01;34m\] \${NEW_PWD}\n     >\\$\[\033[00m\] "
  fi
 }

Leave a Reply