File: cd.fish

package info (click to toggle)
fish 1.23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 6,416 kB
  • ctags: 2,503
  • sloc: ansic: 35,998; sh: 2,818; makefile: 566
file content (36 lines) | stat: -rw-r--r-- 619 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# The following functions add support for a directory history
#

function cd --description "Change directory"

	# Skip history in subshells
	if status --is-command-substitution
		builtin cd $argv
		return $status
	end

	# Avoid set completions
	set -l previous $PWD

	if test $argv[1] = - ^/dev/null
		if test $__fish_cd_direction = next ^/dev/null
			nextd
		else
			prevd
		end
		return $status
	end
				
	builtin cd $argv[1]
	set -l cd_status $status

	if test $cd_status = 0 -a $PWD != $previous
		set -g dirprev $dirprev $previous
		set -e dirnext
		set -g __fish_cd_direction prev
	end

	return $cd_status
end