Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Last active August 29, 2015 13:56
Show Gist options
  • Save lukemorton/8868444 to your computer and use it in GitHub Desktop.
Save lukemorton/8868444 to your computer and use it in GitHub Desktop.
Fish Config
function g; git $argv; end
function ll; ls -laH $argv; end
set fish_user_paths $fish_user_paths ~/Repositories/adt/sdk/platform-tools
set fish_user_paths $fish_user_paths ~/Repositories/adt/sdk/tools
function _git_branch_name
set -l branch (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
if test -n "$branch"
echo $branch
else
set -l commit (command git rev-parse --short HEAD ^/dev/null)
if test -n "$commit"
set_color red
echo $commit
end
end
end
function _git_status_symbol
set -l stashed (command git stash list ^/dev/null | tail -n1)
set -l changed (command git status --porcelain ^/dev/null)
if test -n "$stashed"
echo -n ' $'
end
if test -n "$changed"
set -l dirty (command git diff --shortstat ^/dev/null)
if test -n "$dirty"
echo -n ' *'
else
echo -n ' +'
end
end
echo ''
end
function git_prompt
set -l git_status (_git_branch_name)(_git_status_symbol)
if test -n "$git_status"
echo -n " ("
set_color cyan
echo -n "$git_status"
set_color normal
echo -n ")"
end
end
function fish_prompt
set_color $fish_color_cwd
printf '%s' (prompt_pwd)
set_color normal
git_prompt
echo '> '
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment