Add support for ignoring VCS directories

Signed-off-by: Jesper Derehag <jderehag@hotmail.com>
This commit is contained in:
Jesper Derehag 2017-10-26 14:27:08 +02:00 committed by Justin Hileman
parent 4e602d98d7
commit 2673d2c39d
2 changed files with 16 additions and 0 deletions

View File

@ -170,6 +170,9 @@ variables to set the colors of the prompt. See the "Colors" section of
`fish_prompt.fish` for details.
**VCS options**
- `set -g theme_vcs_ignore_paths /some/path/* /some/other/path`. Tells bobthefish to ignore paths for Git or Mercurial. Supports glob patterns.
### Overrides
You can disable the theme default greeting, vi mode prompt, right prompt, or title entirely — or override with your own — by adding custom functions to `~/.config/fish/functions`:

View File

@ -92,8 +92,19 @@ function __bobthefish_pretty_parent -S -a current_dir -d 'Print a parent directo
string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' "$parent_dir/"
end
function __ignore_vcs_dir -d 'Identifies if dir is to be ignored for VCS highlighting'
for path_ in $theme_vcs_ignore_paths
if [ (string match (realpath $path_ ^/dev/null) (realpath $PWD ^/dev/null)) ]
echo 1
break
end
end
end
function __bobthefish_git_project_dir -S -d 'Print the current git project base directory'
[ "$theme_display_git" = 'no' ]; and return
[ (__ignore_vcs_dir) ]; and return
if [ "$theme_git_worktree_support" != 'yes' ]
command git rev-parse --show-toplevel ^/dev/null
return
@ -138,6 +149,8 @@ end
function __bobthefish_hg_project_dir -S -d 'Print the current hg project base directory'
[ "$theme_display_hg" = 'yes' ]; or return
[ (__ignore_vcs_dir) ]; and return
set -l d $PWD
while not [ $d = / ]
if [ -e $d/.hg ]