2006-02-08 10:20:43 +00:00
|
|
|
#
|
|
|
|
# The following functions add support for a directory history
|
|
|
|
#
|
|
|
|
|
2007-01-16 01:29:18 +00:00
|
|
|
function cd --description "Change directory"
|
2006-02-08 10:20:43 +00:00
|
|
|
|
|
|
|
# Skip history in subshells
|
|
|
|
if status --is-command-substitution
|
|
|
|
builtin cd $argv
|
|
|
|
return $status
|
|
|
|
end
|
|
|
|
|
|
|
|
# Avoid set completions
|
2006-06-17 13:11:45 +00:00
|
|
|
set -l previous $PWD
|
2006-02-08 10:20:43 +00:00
|
|
|
|
|
|
|
if test $argv[1] = - ^/dev/null
|
2009-02-01 22:20:58 +00:00
|
|
|
if test "$__fish_cd_direction" = next ^/dev/null
|
2006-02-08 10:20:43 +00:00
|
|
|
nextd
|
|
|
|
else
|
|
|
|
prevd
|
|
|
|
end
|
|
|
|
return $status
|
|
|
|
end
|
2010-09-18 02:18:26 +00:00
|
|
|
|
2006-02-08 10:20:43 +00:00
|
|
|
builtin cd $argv[1]
|
2006-06-16 15:18:48 +00:00
|
|
|
set -l cd_status $status
|
2006-02-08 10:20:43 +00:00
|
|
|
|
2009-02-01 22:20:58 +00:00
|
|
|
if test $cd_status = 0 -a "$PWD" != "$previous"
|
2006-02-08 10:20:43 +00:00
|
|
|
set -g dirprev $dirprev $previous
|
|
|
|
set -e dirnext
|
|
|
|
set -g __fish_cd_direction prev
|
|
|
|
end
|
|
|
|
|
2006-06-16 15:18:48 +00:00
|
|
|
return $cd_status
|
2006-02-08 10:20:43 +00:00
|
|
|
end
|
|
|
|
|