Skip to content

Instantly share code, notes, and snippets.

@sidharthv96
Forked from ronaldsuwandi/config.fish
Last active April 25, 2018 13:54
Show Gist options
  • Save sidharthv96/9b1df8fefc76b5177cda1218ccad6db9 to your computer and use it in GitHub Desktop.
Save sidharthv96/9b1df8fefc76b5177cda1218ccad6db9 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
function adbc --description 'ADB Network Connect'
command adb connect $argv
end
function ls --description 'List contents of directory'
command ls -lFG $argv
end
function subl --description 'Launches sublime text in a new window'
command subl -n $argv
end
function code --description 'Launches Visual studio code in a new window'
command code -n $argv
end
function gf --description 'Do a git fetch'
command git fetch
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
# Path to Oh My Fish install.
set -q XDG_DATA_HOME
and set -gx OMF_PATH "$XDG_DATA_HOME/omf"
or set -gx OMF_PATH "$HOME/.local/share/omf"
# Load Oh My Fish configuration.
source $OMF_PATH/init.fish
alias pm='python manage.py'
alias p='python'
alias h='history'
alias d='cd ~/dev/'
alias ssh='ssh -v'
set -x LC_ALL en_US.UTF-8
set -x LANG en_US.UTF-8
set -x ANDROID_HOME /Users/sidharthvinod/Library/Android/sdk
set -gx PATH $PATH $ANDROID_HOME/tools $ANDROID_HOME/platform-tools $HOME/dev/flutter/bin /usr/local/opt/qt/bin
set -gx LSCOLORS gxfxcxdxbxegedabagacad
set -gx CLICOLOR 1
set -gx TERM xterm-256color
# . $HOME/.config/fish/conf.d/prompt.fish
# set -gx HOMEBREW_GITHUB_API_TOKEN #token here#
# 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