Skip to content

Instantly share code, notes, and snippets.

@nikopol
Last active July 9, 2021 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikopol/eda66eaf18f3b8b92f65 to your computer and use it in GitHub Desktop.
Save nikopol/eda66eaf18f3b8b92f65 to your computer and use it in GitHub Desktop.
function fish_prompt
set sepcol (set_color -o blue)
set hstcol (set_color -o yellow)
set pthcol (set_color cyan)
set gitcol (set_color normal)
if test $USER = "root"
set usrcol (set_color red)
else
set usrcol (set_color -o green)
end
set gitbranch (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
set gitprompt
if test "$gitbranch" != ""
set gitstcount (git status -s --ignore-submodules=dirty --untracked-files=no ^/dev/null | wc -l)
if test $gitstcount -gt 0
set gitprompt (printf '%s[%s%s:%d%s]' $sepcol $gitcol $gitbranch $gitstcount $sepcol)
else
set gitprompt (printf '%s[%s%s%s]' $sepcol $gitcol $gitbranch $sepcol)
end
end
printf '%s%s%s@%s%s%s:%s%s%s%s▶%s ' $usrcol (whoami) $sepcol $hstcol (hostname|cut -d . -f 1) $sepcol $pthcol (prompt_pwd) $gitprompt $sepcol (set_color normal)
end
@nikopol
Copy link
Author

nikopol commented Apr 12, 2017

in ~/.config/fish/functions/

@nikopol
Copy link
Author

nikopol commented Jul 9, 2021

^/dev/null becomes 2>/dev/null for fish >= 3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment