|
|
|
@ -28,31 +28,16 @@ function __syl20bnr_git_repo_base -d "Return the current repository name"
|
|
|
|
|
echo (command git rev-parse --show-toplevel ^/dev/null)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function __syl20bnr_is_git_dirty -d "Check if there is uncommited changes"
|
|
|
|
|
echo (command git status -s --ignore-submodules=dirty ^/dev/null)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function __syl20bnr_is_git_ahead -d "Check if there is unpushed commits"
|
|
|
|
|
echo (command git status -s -b ^/dev/null | grep ahead)
|
|
|
|
|
function __syl20bnr_git_status -d "git status command"
|
|
|
|
|
git status -b -s --ignore-submodules=dirty
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function __syl20bnr_unpushed_commit_count -d "Return the number of unpushed commits"
|
|
|
|
|
git status -s -b ^/dev/null | grep -E -o "ahead\ [0-9]+" | awk '{print $2}'
|
|
|
|
|
echo $argv[1] | grep -E -o "ahead\ [0-9]+" | awk '{print $2}'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function fish_vi_prompt_cm --description "Displays the current mode"
|
|
|
|
|
switch $fish_bind_mode
|
|
|
|
|
case default
|
|
|
|
|
set_color --bold --background red white
|
|
|
|
|
echo "[N]"
|
|
|
|
|
case insert
|
|
|
|
|
set_color --bold --background green white
|
|
|
|
|
echo "[I]"
|
|
|
|
|
case visual
|
|
|
|
|
set_color --bold --background magenta white
|
|
|
|
|
echo "[V]"
|
|
|
|
|
end
|
|
|
|
|
set_color normal
|
|
|
|
|
function __syl20bnr_unmerged_commit_count -d "Return the number of unmerged commits"
|
|
|
|
|
echo $argv[1] | grep -E -o "behind\ [0-9]+" | awk '{print $2}'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
@ -94,27 +79,34 @@ function fish_prompt -d "Write out the left prompt of the syl20bnr theme"
|
|
|
|
|
# P is the current working path basename (name of the current directory)
|
|
|
|
|
# C is the depth of the path starting from base directory of the repo
|
|
|
|
|
# The displayed information is:
|
|
|
|
|
# Dirtiness is indicated by a little dot after the branch name.
|
|
|
|
|
# Unpushed commits are indicated with up arrows
|
|
|
|
|
# The number of unpushed commits is indicated right after the up arrows
|
|
|
|
|
# Note:
|
|
|
|
|
# Dirtiness is indicated by the color of the branch name, red is dirty,
|
|
|
|
|
# green is up-to-date.
|
|
|
|
|
# If P = Z then P(C) is not displayed
|
|
|
|
|
set -l ps_git ""
|
|
|
|
|
set -l git_branch_name (__syl20bnr_git_branch_name)
|
|
|
|
|
if test -n "$git_branch_name"
|
|
|
|
|
set -l git_repo_name (__syl20bnr_git_repo_name)
|
|
|
|
|
set -l git_info ""
|
|
|
|
|
if test -n (__syl20bnr_is_git_ahead)
|
|
|
|
|
set git_info $colbgreen"↑↑↑"$colnormal"("(__syl20bnr_unpushed_commit_count)")"
|
|
|
|
|
set -l git_status (__syl20bnr_git_status)
|
|
|
|
|
if echo $git_status | grep ahead > /dev/null
|
|
|
|
|
set git_info "["$colbgreen"↑"(__syl20bnr_unpushed_commit_count $git_status)$colnormal"]"
|
|
|
|
|
end
|
|
|
|
|
if test -n (__syl20bnr_is_git_dirty)
|
|
|
|
|
set git_info $git_info$colbred"·"
|
|
|
|
|
if echo $git_status | grep behind > /dev/null
|
|
|
|
|
set git_info "$git_info""["$colbred"↓"(__syl20bnr_unmerged_commit_count $git_status)$colnormal"]"
|
|
|
|
|
end
|
|
|
|
|
set ps_git $colbwhite"git:"$colbcyan$git_branch_name$git_info$colnormal"@"$colbred$git_repo_name
|
|
|
|
|
set -l colbranch $colbgreen
|
|
|
|
|
if echo $git_status | grep -E "\s\?\?\s|\sM\s|\sD\s" > /dev/null
|
|
|
|
|
set colbranch $colbred
|
|
|
|
|
end
|
|
|
|
|
set ps_git $colbwhite"git:"$colbcyan$git_branch_name$git_info$colnormal"@"$colbranch$git_repo_name
|
|
|
|
|
if test "$basedir_name" != "$git_repo_name"
|
|
|
|
|
set -l basedir_depth (echo (__syl20bnr_git_repo_base) | sed "s/\// /g" | wc -w)
|
|
|
|
|
set -l depth (echo (pwd) | sed "s/\// /g" | wc -w)
|
|
|
|
|
set depth (math $depth - $basedir_depth)
|
|
|
|
|
set ps_git $ps_git$colbwhite":"$colbgreen$basedir_name$colnormal"("$depth")"
|
|
|
|
|
set ps_git $ps_git$colnormal":"$colbwhite$basedir_name$colnormal"("$depth")"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -151,7 +143,14 @@ function fish_prompt -d "Write out the left prompt of the syl20bnr theme"
|
|
|
|
|
set ps_vi $colnormal"["$vi_mode$colnormal"]"
|
|
|
|
|
end
|
|
|
|
|
if test "$fish_key_bindings" = "fish_vi_key_bindings" -o "$fish_key_bindings" = "my_fish_key_bindings"
|
|
|
|
|
set ps_vi (fish_vi_prompt_cm)
|
|
|
|
|
switch $fish_bind_mode
|
|
|
|
|
case default
|
|
|
|
|
set ps_vi $colnormal"("$colred"N"$colnormal")"
|
|
|
|
|
case insert
|
|
|
|
|
set ps_vi $colnormal"("$colgreen"I"$colnormal")"
|
|
|
|
|
case visual
|
|
|
|
|
set ps_vi $colnormal"("$colwhite"V"$colnormal")"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# end of prompt
|
|
|
|
|