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.
This commit is contained in:
Fabian Homborg 2018-11-29 19:33:43 +01:00
parent 8ee2e54c9b
commit eb0dd1ea78

View file

@ -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)"