-
Notifications
You must be signed in to change notification settings - Fork 0
/
fish_prompt.fish
49 lines (42 loc) · 954 Bytes
/
fish_prompt.fish
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
37
38
39
40
41
42
43
44
45
46
47
48
49
function minima_path_to_array
echo $argv[1] | sed 's:/:\n:g'
end
function minima_shortened_path
set long (minima_path_to_array $PWD)
set short (minima_path_to_array $argv[1])
set start (count $short)
set end (count $long)
for i in (seq $start $end)
echo -n $long[$i]
if [ $i -lt $end ]
echo -n '/'
end
end
end
function minima_pwd
set repos_root (git rev-parse --show-toplevel 2> /dev/null)
if [ $status = 0 ]
set dir (minima_shortened_path $repos_root)
else
set dir $PWD
end
echo $dir | sed -E 's:^'$HOME':~:'
end
function fish_prompt
set -g last_status $status
tput bold
if test $last_status -ne 0
set_color red
else
set_color green
end
if test (id -u $USER) -eq 0
echo -n '# '
else
echo -n '❯ '
end
set_color white
echo -n (minima_pwd)
tput sgr0
echo -n ' '
end