prompt: Show untracked Git files relative to root directory (#4874)

* prompt/git: Match untracked files relative to root directory

* prompt/git: Move untracked file logic to a separate function
This commit is contained in:
George Christou 2018-04-09 00:05:03 +01:00 committed by Fabian Homborg
parent 01f24f2df6
commit c6e7b7ef00

View file

@ -387,9 +387,7 @@ function __fish_git_prompt --description "Prompt function for Git"
if set -q __fish_git_prompt_showuntrackedfiles if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles) set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false if test "$config" != false
if command git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- '*' >/dev/null 2>/dev/null set u (__fish_git_prompt_untracked)
set u $___fish_git_prompt_char_untrackedfiles
end
end end
end end
end end
@ -471,6 +469,14 @@ function __fish_git_prompt_staged --description "__fish_git_prompt helper, tells
echo $staged echo $staged
end end
function __fish_git_prompt_untracked --description "__fish_git_prompt helper, tells whether or not the current repository has untracked files"
set -l untracked
if command git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- :/ >/dev/null 2>&1
set untracked $___fish_git_prompt_char_untrackedfiles
end
echo $untracked
end
function __fish_git_prompt_dirty --description "__fish_git_prompt helper, tells whether or not the current branch has tracked, modified files" function __fish_git_prompt_dirty --description "__fish_git_prompt helper, tells whether or not the current branch has tracked, modified files"
set -l dirty set -l dirty