Skip to content

Instantly share code, notes, and snippets.

@zacbir
Created July 2, 2014 15:47
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 zacbir/4eb4fdff14ece15709cf to your computer and use it in GitHub Desktop.
Save zacbir/4eb4fdff14ece15709cf to your computer and use it in GitHub Desktop.
Fish prompt
function parse_git_dirty
set -x git_output (git status 2> /dev/null | tail -n1)
if test $git_output
if test $git_output = "nothing to commit, working directory clean"
echo -n green
return
else
echo -n yellow
return
end
end
echo -n normal
end
function parse_git_branch
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [git:\1]/"
end
# bzr (expects to use bzr-colo: https://launchpad.net/bzr-colo)
function parse_bzr_dirty
set -x bzr_output (bzr st 2> /dev/null | tail -n1)
if test -z $bzr_output
echo -n green
return
else
echo -n yellow
return
end
echo -n normal
end
function parse_bzr_branch
bzr colo-branches 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [bzr:\1]/"
end
# hg
function parse_hg_dirty
set -x hg_output (hg status 2> /dev/null | tail -n1)
if test -z $hg_output
echo -n green
return
else
echo -n yellow
return
end
echo -n normal
end
function parse_hg_branch
hg branches 2> /dev/null | cut -d ' ' -f 1 | sed -e "s/\(.*\)/ [hg:\1]/"
end
# combined
function parse_dvcs_branch
set_color (parse_bzr_dirty)
echo -n (parse_bzr_branch)
set_color normal
set_color (parse_git_dirty)
echo -n (parse_git_branch)
set_color normal
set_color (parse_hg_dirty)
echo -n (parse_hg_branch)
set_color normal
end
# Only intended as inspiration - captures info pertinent to Zac's setup
function fish_prompt
echo -n (whoami)@(hostname -s)" "
set_color $fish_color_cwd
echo -n (prompt_pwd)
echo (parse_dvcs_branch)
set_color normal
echo -n '$ '
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment