Posted By

robh on 01/18/08


Tagged

Bash osx dynamic prompt


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

leachypeachy
snucko
nimoyjohnson
srinivasga
AzizLight
scilec
vthreex


Dynamic BASH Prompt


 / Published in: Bash
 

URL: http://blog.ubrio.us/osx/best-bash-prompt/

A very dynamic and flexible bash prompt. Personally I find this to have everything needed. It shows exit status, shortens itself for long directories, and shows bash history for easy referencing.

Hopefully it doesn't get messed up.

  1. export MAX_PATH_LENGTH=25
  2. export PROMPT_COMMAND='PS1="\[\033[0;33m\][\!]\`if [[ \$? = "0" ]]; then echo "\\[\\033[32m\\]"; else echo "\\[\\033[31m\\]"; fi\`[\u.\h: \`if [[ `pwd|wc -c|tr -d " "` > $MAX_PATH_LENGTH ]]; then echo "\\W"; else echo "\\w"; fi\`]\$\[\033[0m\] "; echo -ne "\033]0;`hostname -s`:`pwd`\007"'

Report this snippet  

You need to login to post a comment.