Skip to content

Instantly share code, notes, and snippets.

@mgaebler
Forked from ronaldsuwandi/config.fish
Last active November 19, 2017 13:37
Show Gist options
  • Save mgaebler/066466ce0599da1e5abaaf93be716e5d to your computer and use it in GitHub Desktop.
Save mgaebler/066466ce0599da1e5abaaf93be716e5d to your computer and use it in GitHub Desktop.
My personal fish shell config for OS X (better blue colour for directory in dark terminal). Supports git branch
# nice light cyan color instead of dark blue
set -gx LSCOLORS gxfxcxdxbxegedabagacad
function ls --description 'List contents of directory'
command ls -lFG $argv
end
function code --description 'Launches visual code studio in a new window'
command code -n $argv
end
function grep --description 'Colorful grep that ignores binary file and outputs line number'
command grep --color=always -I $argv
end
function gdeletemergedcurrent --description 'Delete all local branches that is already merged to current branch (exludes master)'
command git branch --merged | grep -v "\*" | grep -v "master" | xargs -n 1 git branch -d
command git remote prune origin
end
set -gx GOPATH $HOME/Go
set -gx GOROOT (go env GOROOT)
set PATH $HOME/bin $GOPATH/bin $HOME/.rbenv/shims /usr/local/bin /usr/local/sbin $PATH $GOROOT/bin ./node_modules/.bin
. $HOME/.config/fish/prompt.fish
# set -gx HOMEBREW_GITHUB_API_TOKEN #token here#
# Java
set -gx JAVA_HOME (/usr/libexec/java_home)
# Allow 256 colors in iTerm2 for pretty vim colors
set -gx CLICOLOR 1
set -gx TERM xterm-256color
# use custom function instead of fish built in git prompt due to performance
# (fish git prompt uses diff which can be slow)
function git_prompt
# uses simple grep and colrm instead of complicated sed regex
set -l branch (git branch 2> /dev/null | grep --color=never -e '*.\(.*\)' | colrm 1 2)
# use git status to improve performance (instead of using diff)
# [MADRC] - if file is modified
# ? - if untracked file exists
set -l git_dirty (git status -s | colrm 3 | colrm 1 1 | grep --color=never -e '[MADRC]')
set -l git_untracked (git status -s | colrm 3 | colrm 1 1 | grep --color=never -e '?')
set -l git_stashed (git stash list | head -n 1)
if test -n "$git_dirty"
printf ' (%s%s' (set_color red) $branch
else
printf ' (%s%s' (set_color yellow) $branch
end
if test -n "$git_untracked"
printf '%s*' (set_color purple)
end
if test -n "$git_stashed"
printf '%s$' (set_color green)
end
set -l git_status_origin (git status -s -b | head -n 1)
set -l ahead (echo $git_status_origin | grep --color=never -e '\[.*ahead.*\]')
set -l behind (echo $git_status_origin | grep --color=never -e '\[.*behind.*\]')
# if local repo is ahead, show up arrow
if test -n "$ahead"
printf '%s↑' (set_color cyan)
end
# if local repo is behind, show down arrow
if test -n "$behind"
printf '%s↓' (set_color magenta)
end
printf '%s)' (set_color normal)
end
function fish_prompt
if not [ -z $VIRTUAL_ENV ]
printf '%s(%s)%s ' (set_color -b cyan black) (basename "$VIRTUAL_ENV") (set_color normal)
end
printf '%s%s%s' (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
if test -d .git
printf '%s' (git_prompt)
end
printf ' ☕️ '
set_color normal
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment