aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/prompt_pwd.fish
blob: 7f892c70052136c77940bd94d6e1cf343b99e36c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

if test (uname) = Darwin
	function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
		if test "$PWD" != "$HOME"
			printf "%s" (echo $PWD|sed -e 's|/private||' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
			echo $PWD|sed -e 's-.*/\.\{0,1\}[^/]\([^/]*$\)-\1-'
		else
			echo '~'
		end
	end
else
	function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
		switch "$PWD"
			case "$HOME"
			echo '~'

			case '*'
			printf "%s" (echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
			echo $PWD|sed -n -e 's-.*/\.\{0,1\}.\([^/]*\)-\1-p'
		end
	end
end