Skip to content

Instantly share code, notes, and snippets.

@ehabkost
Created July 30, 2010 20:08
Show Gist options
  • Save ehabkost/501229 to your computer and use it in GitHub Desktop.
Save ehabkost/501229 to your computer and use it in GitHub Desktop.
. /mnt/common/sys/scripts/git-completion.bash
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
_git_cur_branch()
{
__git_ps1
return
# the code below is dead. it is the old git-current-branch code I was using
local id="$(git rev-parse HEAD 2> /dev/null)"
if [ -z "$id" ];then
return 0
fi
local r="$(git symbolic-ref -q HEAD 2>/dev/null)"
if [ -z "$r" ];then
# not a branch. try to find a tag, then
#match="$(git show-ref -d --tags | grep "$id" | head -1 | cut -d' ' -f2)"
match=""
if [ -n "$match" ];then
r="/${match/refs\//}"
r="${r/^\{\}/}"
else
r="/${id::6}..."
fi
else
r="/${r/refs\/heads\//}"
fi
echo "$r"
}
_screen_title() {
if [ "$TERM" = "screen" ];then
echo -e '\ek'"$(basename "$PWD")"'\e\\'
fi
}
PS1='(green\urst@blue\hrst:bright\wrst `ret=$?;if [ $ret != 0 ];then echo -e "red($ret)";else echo -e "green(ok)";fi`rstblue`if [ "\j" -gt 0 ];then echo " \jj";fi`rst)rst\nrst[bright\Wcyan`_git_cur_branch`rst]\[`_screen_title`\]\$rst '
# I'm to lazy to retype escape sequences 8)
green='\e[40;32m'
blue='\e[40;34;1m'
cyan='\e[40;36;1m'
bright='\e[40;37;1m'
red='\e[40;31;1m'
rst='\e[0m'
for part in green blue cyan bright red rst;do
eval "PS1=\"\${PS1//$part/\\[\$$part\\]}\""
eval "unset $part"
done
export EDITOR=vim
export VISUAL=vim
export PATH=$PATH:/mnt/common/sys/scripts
set -o vi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment