2015-08-26 21:28:16 +00:00
|
|
|
# name: ifij (forked from RobbyRussel)
|
2015-06-03 20:53:20 +00:00
|
|
|
#
|
|
|
|
# You can override some default options in your config.fish:
|
|
|
|
# set -g theme_display_git_untracked no
|
|
|
|
|
2015-08-26 21:28:16 +00:00
|
|
|
function _status_color
|
|
|
|
# Returns a color for successful or failed previous command
|
|
|
|
if test $last_status -eq 0
|
|
|
|
echo (set_color -o green)
|
|
|
|
else
|
|
|
|
echo (set_color -o red)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-03 20:53:20 +00:00
|
|
|
function _git_branch_name
|
2015-08-26 21:28:16 +00:00
|
|
|
# Returns the name of the current git branch
|
2015-06-03 20:53:20 +00:00
|
|
|
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
|
|
|
|
end
|
|
|
|
|
|
|
|
function _is_git_dirty
|
2015-08-26 21:28:16 +00:00
|
|
|
# Returns whether or not there is anything uncommitted
|
2015-06-03 20:53:20 +00:00
|
|
|
set -l show_untracked (git config --bool bash.showUntrackedFiles)
|
|
|
|
set untracked ''
|
|
|
|
if [ "$theme_display_git_untracked" = 'no' -o "$show_untracked" = 'false' ]
|
|
|
|
set untracked '--untracked-files=no'
|
|
|
|
end
|
|
|
|
echo (command git status -s --ignore-submodules=dirty $untracked ^/dev/null)
|
|
|
|
end
|
|
|
|
|
2015-08-26 21:28:16 +00:00
|
|
|
function _git_info
|
|
|
|
# Returns what is to be displayed for the git info
|
|
|
|
if [ (_git_branch_name) ]
|
|
|
|
if [ (_is_git_dirty) ]
|
|
|
|
set branch_color (set_color -o red)
|
|
|
|
else
|
|
|
|
set branch_color (set_color -o yellow)
|
|
|
|
end
|
|
|
|
set -l git_branch (_git_branch_name)
|
|
|
|
echo " $branch_color($git_branch)"(set_color normal)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function _hostname
|
|
|
|
# Returns the hostname if not using tmux since tmux will display
|
|
|
|
if [ -z $TMUX ]
|
|
|
|
echo (hostname)" "
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-03 20:53:20 +00:00
|
|
|
function _prompt_char
|
2015-08-26 21:28:16 +00:00
|
|
|
# Gives a colored prompt char for user or root
|
|
|
|
echo -n (_status_color)
|
2015-06-03 20:53:20 +00:00
|
|
|
if [ (whoami) = 'root' ]
|
2015-08-26 21:28:16 +00:00
|
|
|
echo -n '#'
|
2015-06-03 20:53:20 +00:00
|
|
|
else
|
2015-08-26 21:28:16 +00:00
|
|
|
echo -n '$'
|
2015-06-03 20:53:20 +00:00
|
|
|
end
|
2015-08-26 21:28:16 +00:00
|
|
|
echo -n (set_color normal)
|
2015-06-03 20:53:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function fish_prompt
|
2015-08-26 21:28:16 +00:00
|
|
|
# Build full left side prompt
|
|
|
|
|
|
|
|
# NOTE: this becomes a global variable
|
|
|
|
set -g last_status $status
|
|
|
|
|
2015-06-03 20:53:20 +00:00
|
|
|
set -l cyan (set_color -o cyan)
|
|
|
|
set -l yellow (set_color -o yellow)
|
|
|
|
set -l red (set_color -o red)
|
|
|
|
set -l blue (set_color -o blue)
|
|
|
|
set -l green (set_color -o green)
|
|
|
|
set -l normal (set_color normal)
|
|
|
|
|
2015-08-26 21:28:16 +00:00
|
|
|
set -l arrow (_status_color) "➜ $normal"
|
|
|
|
set -l cwd (basename (prompt_pwd))
|
2015-06-03 20:53:20 +00:00
|
|
|
|
2015-08-26 21:28:16 +00:00
|
|
|
echo -n -s $arrow (_hostname) $cwd (_git_info) (_prompt_char) ' '
|
2015-06-03 20:53:20 +00:00
|
|
|
end
|
|
|
|
|