# Produces a nice, colorful 2-line prompt of the form: # [username@hostname:current_directory] (git_repo|branch) # $ source ./colorize.sh function super_prompt { local git_dir=$(git rev-parse --show-toplevel 2>/dev/null) if [ "$git_dir" != "" ]; then local path=$(colorize green ${PWD//$git_dir/\!}) else local path=$(colorize green ${PWD//$HOME/\~}) fi local git_branch=$(git branch 2>/dev/null | grep "*" | cut -d ' ' -f 2) || "" if [ "$git_branch" != "" ]; then local git_repo=$(git rev-parse --show-toplevel) git_branch=\($(colorize magenta ${git_repo//*\/})"|"$(colorize magenta ${git_branch})\) fi local user=$(colorize yellow $(whoami)) local host=$(colorize blue ${HOSTNAME}) local prompt_char=$(colorize red '$') prompt=$(printf "[%s@%s:%s] %s\n\f\r%s " "$user" "$host" "$path" "$git_branch" "$prompt_char") echo $prompt } # export PS1=super_prompt