Skip to content

Instantly share code, notes, and snippets.

@mheffner
Created September 7, 2012 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mheffner/3666541 to your computer and use it in GitHub Desktop.
Save mheffner/3666541 to your computer and use it in GitHub Desktop.
My full PS1
# Prompt
export PROMPT_DIRTRIM=3
function getwintitle()
{
case $TERM in
xterm*|rxvt|Eterm|eterm)
# Set icon title
printf "\[\e]1;\h:\`basename '\w'\`\007\]"
# Set window title
printf "\[\e]2;\h:\w\007\]"
;;
screen)
printf "\[\e_\h:\w\e\\"
;;
*)
;;
esac
}
# Emulate %c from tcsh
# Stolen from: http://bsdjlh.blogspot.com/2009/02/bash-prompt-trick-cheap-emulation-of.html
# (with minor mods)
function traildir()
{
local n=$1 dir=$2
local sl tildedir homelen shifted traildir
local oldifs=$IFS
tildedir=${dir#$HOME}
if ! [[ "$tildedir" == "$dir" ]]; then
# Special break out case
[[ -z "$tildedir" ]] && { echo "~"; return 0; }
sl="~/"
else
sl="/"
fi
set -- ${HOME//\// }
homelen=$#
shifted=0
IFS="/"
set -- ${tildedir/\//}
if [[ $# -gt $n ]]; then
shifted=$(($# - $n))
shift $shifted
traildir="$sl<$shifted>/$*"
else
traildir="$sl$*"
fi
IFS=$oldifs
echo $traildir
}
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Show dirty state
export GIT_PS1_SHOWDIRTYSTATE=1
TRAILPWD=3
export PS1="\h\\[\e[1;31m\]\$(__git_ps1 \"(%s)\")\[\e[m\]:\[\`tput bold\`\]\$(traildir \$TRAILPWD \"\$PWD\")\[\`tput sgr0\`\]$ `getwintitle`"
# From: http://blog.jasonmeridth.com/2010/05/22/git-ps1.html
source ~/.git-completion.bash
export PS1='\w$(__git_ps1 "(%s)") > '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment