Created
August 10, 2012 17:07
-
-
Save zacbir/3315716 to your computer and use it in GitHub Desktop.
fish_prompt.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add to ~/.config/fish/functions/fish_prompt.fish | |
function parse_git_dirty | |
set -x git_output (git status 2> /dev/null | tail -n1) | |
if test $git_output | |
test $git_output = "nothing to commit (working directory clean)"; or echo -n "*" | |
end | |
end | |
function parse_git_branch | |
set -x dirty (parse_git_dirty) | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[git:\1$dirty]/" | |
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) | |
test -z $bzr_output; or echo -n "*" | |
end | |
function parse_bzr_branch | |
set -x dirty (parse_bzr_dirty) | |
bzr colo-branches 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[bzr:\1$dirty]/" | |
end | |
# combined | |
function parse_dvcs_branch | |
echo -n (parse_bzr_branch); and echo -n (parse_git_branch) | |
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