Skip to content

Instantly share code, notes, and snippets.

@sofide
Created May 27, 2020 13:43
Show Gist options
  • Save sofide/f05e404bee0b98adf7bf10377f29f5e8 to your computer and use it in GitHub Desktop.
Save sofide/f05e404bee0b98adf7bf10377f29f5e8 to your computer and use it in GitHub Desktop.
fish config based on fisa fish config
alias g git
# name: fidan (based on idan theme, but simplified)
# Display the following bits on the left:
# * Current directory name
# * Git branch and dirty state (if inside a git repo)
function _git_branch_name
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _is_git_dirty
echo (command git status -s --ignore-submodules=dirty ^/dev/null)
end
function fish_prompt
set -l prompt_color (set_color -o 8BE8AC)
set -l git_dirty_color (set_color -o yellow)
set -l git_clean_color (set_color -o green)
set -l normal (set_color normal)
# output the prompt, left to right
# Add a newline before prompts
# (removed because it breaks with virtualenv prefixes)
# echo -e ""
# Display the current directory name
set -l cwd (basename (prompt_pwd))
echo -n -s $prompt_color $cwd
# Show git branch and dirty state
if [ (_git_branch_name) ]
set -l git_branch '' (_git_branch_name) ''
if [ (_is_git_dirty) ]
set git_info $git_dirty_color $git_branch
else
set git_info $git_clean_color $git_branch
end
echo -n -s ' ' $git_info
end
# Terminate with a nice prompt char
echo -n -s $prompt_color ' ❯ ' $normal
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment