From eb0dd1ea7891b16d2964cc480e1f7f4457c280f4 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 29 Nov 2018 19:33:43 +0100 Subject: [PATCH] sample_prompts/robbyrussell: Clean - Remove use of `eval` - Use `git rev-parse` instead of `git status` as its faster, - especially in large repos. (in qt5: 600ms vs 1ms) - Use return status instead of test -n This should change nothing about the output. --- .../web_config/sample_prompts/robbyrussell.fish | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/share/tools/web_config/sample_prompts/robbyrussell.fish b/share/tools/web_config/sample_prompts/robbyrussell.fish index f539027df..ccc48bd9d 100644 --- a/share/tools/web_config/sample_prompts/robbyrussell.fish +++ b/share/tools/web_config/sample_prompts/robbyrussell.fish @@ -22,7 +22,7 @@ function fish_prompt function _is_git_repo type -q git or return 1 - git status -s >/dev/null 2>/dev/null + git rev-parse --git-dir >/dev/null 2>&1 end function _hg_branch_name @@ -40,19 +40,22 @@ function fish_prompt end function _repo_branch_name - eval "_$argv[1]_branch_name" + _$argv[1]_branch_name end function _is_repo_dirty - eval "_is_$argv[1]_dirty" + _is_$argv[1]_dirty end function _repo_type if _is_hg_repo echo 'hg' + return 0 else if _is_git_repo echo 'git' + return 0 end + return 1 end end @@ -75,8 +78,7 @@ function fish_prompt set -l cwd $cyan(basename (prompt_pwd)) - set -l repo_type (_repo_type) - if [ $repo_type ] + if set -l repo_type (_repo_type) set -l repo_branch $red(_repo_branch_name $repo_type) set repo_info "$blue $repo_type:($repo_branch$blue)"