Skip to content

Instantly share code, notes, and snippets.

@jonas-schievink
Created December 3, 2021 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonas-schievink/8f7c02bc6d7d4504945f4ae631c81463 to your computer and use it in GitHub Desktop.
Save jonas-schievink/8f7c02bc6d7d4504945f4ae631c81463 to your computer and use it in GitHub Desktop.
# A minimal Fish prompt based on the gitstatus prompt.
# Original gitstatus prompt from https://github.com/godfat/fish_prompt-gitstatus
# Adopted by OMF at https://github.com/oh-my-fish/theme-gitstatus
function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
end
function _git_status_symbol
set -l git_status (git status --porcelain 2> /dev/null)
if test -n "$git_status"
echo '*' # dirty
else
echo '' # clean
end
end
function _remote_hostname
if test -n "$SSH_CONNECTION"
echo (whoami)@(hostname)
end
end
function fish_prompt
set -l cyan (set_color cyan)
set -l normal (set_color normal)
set -l cwd (set_color $fish_color_cwd)(prompt_pwd)
set -l git_status (_git_status_symbol)(_git_branch_name)
if test -n "$git_status"
set git_status " $git_status"
end
echo -n (_remote_hostname) $cwd$cyan$git_status$normal'> '
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment