Skip to content

Instantly share code, notes, and snippets.

@cetinajero
Created April 2, 2018 14:09
Show Gist options
  • Save cetinajero/39d9df69d6cac6d8657dccdb807668a9 to your computer and use it in GitHub Desktop.
Save cetinajero/39d9df69d6cac6d8657dccdb807668a9 to your computer and use it in GitHub Desktop.
vi ~/.config/fish/config.fish
# sudo bang bang
function sudo
if test "$argv" = !!
eval command sudo $history[1]
else
command sudo $argv
end
end
# git branch
set fish_git_dirty_color red
set fish_git_not_dirty_color green
function parse_git_branch
set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/')
set -l git_status (git status -s)
if test -n "$git_status"
echo (set_color $fish_git_dirty_color)$branch(set_color normal)
else
echo (set_color $fish_git_not_dirty_color)$branch(set_color normal)
end
end
function fish_prompt
set -l git_dir (git rev-parse --git-dir 2> /dev/null)
if test -n "$git_dir"
printf '%s@%s %s%s%s:%s> ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (parse_git_branch)
else
printf '%s@%s %s%s%s> ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment