Skip to content

Commit 8894a11

Browse files
committed
split the direnv call into a shared function
1 parent db30829 commit 8894a11

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

fish/cd.fish

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
function _direnv
2+
if test $argv[1] = 0 -a -n "$__fish_direnv"
3+
set -l direnv (eval $__fish_direnv export fish)
4+
eval $direnv
5+
end
6+
end
17
#
28
# The following functions add support for a directory history
39
#
@@ -7,12 +13,8 @@ function cd --description "Change directory"
713
# Skip history in subshells
814
if status --is-command-substitution
915
builtin cd $argv
10-
set -l cd_status $status
11-
if test $cd_status = 0 -a -n "$__fish_direnv"
12-
set -l direnv (eval $__fish_direnv export fish)
13-
eval $direnv
14-
end
15-
16+
set -l cd_status $status
17+
_direnv $status
1618
return $cd_status
1719
end
1820

@@ -26,10 +28,7 @@ function cd --description "Change directory"
2628
prevd
2729
end
2830
set -l cd_status $status
29-
if test $cd_status = 0 -a -n "$__fish_direnv"
30-
set -l direnv (eval $__fish_direnv export fish)
31-
eval $direnv
32-
end
31+
_direnv $cd_status
3332
return $cd_status
3433
end
3534

@@ -42,10 +41,7 @@ function cd --description "Change directory"
4241
set -g __fish_cd_direction prev
4342
end
4443

45-
if test $cd_status = 0 -a -n "$__fish_direnv"
46-
set -l direnv (eval $__fish_direnv export fish)
47-
eval $direnv
48-
end
44+
_direnv $cd_status
4945

5046
return $cd_status
5147
end

0 commit comments

Comments
 (0)