From c6e7b7ef00cf51582bad16cf7b782a9a52b382cd Mon Sep 17 00:00:00 2001 From: George Christou Date: Mon, 9 Apr 2018 00:05:03 +0100 Subject: [PATCH] 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 --- share/functions/__fish_git_prompt.fish | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index e70753445..cc8525a63 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -387,9 +387,7 @@ function __fish_git_prompt --description "Prompt function for Git" if set -q __fish_git_prompt_showuntrackedfiles set -l config (command git config --bool bash.showUntrackedFiles) 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_char_untrackedfiles - end + set u (__fish_git_prompt_untracked) end end end @@ -471,6 +469,14 @@ function __fish_git_prompt_staged --description "__fish_git_prompt helper, tells echo $staged 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" set -l dirty