Skip to content

Instantly share code, notes, and snippets.

@jamie
Created February 26, 2009 16:58
Show Gist options
  • Save jamie/70952 to your computer and use it in GitHub Desktop.
Save jamie/70952 to your computer and use it in GitHub Desktop.
My base fish config files
set PATH ~/bin $PATH
if test -d /opt/local/lib/mysql5/bin/
# include OSX mysql from macports
set PATH $PATH /opt/local/lib/mysql5/bin/
end
# OSX tweaks
if set -q Apple_PubSub_Socket_Render
# bind \cleft and \cright
bind \e\[5D prevd-or-backward-word
bind \e\[5C nextd-or-forward-word
end
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
# different path colors for root prompts
switch $USER
case root
if not set -q __fish_prompt_cwd
if set -q fish_color_cwd_root
set -g __fish_prompt_cwd (set_color $fish_color_cwd_root)
else
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end
end
case '*'
if not set -q __fish_prompt_cwd
set -g __fish_prompt_cwd (set_color $fish_color_cwd)
end
end
# basic prompt
printf '%s@%s %s%s%s' $USER $__fish_prompt_hostname "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal"
# optionally describe current git status
if git symbolic-ref HEAD >/dev/null ^/dev/null
printf ' (git:%s' (git-current-branch)
if not test -z (gitout) >/dev/null ^/dev/null
printf '+%d' (gitout | wc -l | awk '{print $1}')
end
printf ')'
end
# end the prompt
switch $USER
case root
printf '# '
case '*'
printf '> '
end
end
function git-current-branch
# display name of current active branch
git symbolic-ref HEAD ^/dev/null | awk -F/ '{print $3;}'
end
function gitout
# count non-merge commits needing a push to origin
if git cherry -v origin/(git-current-branch) >/dev/null ^/dev/null
# vs outgoing branch if available
git cherry -v origin/(git-current-branch) ^/dev/null
else
# otherwise compare to the master branch
git cherry -v master ^/dev/null
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment