-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfish_right_prompt.fish
56 lines (48 loc) · 1.03 KB
/
fish_right_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
50
51
52
53
54
function fish_right_prompt
set -l exit_code $status
__tmux_prompt
if test $exit_code -ne 0
set_color -o red
else
set_color 666666
end
printf '%d' $exit_code
set_color 666666
printf ' [%s]' (date +%H:%M:%S)
set_color normal
end
function __tmux_prompt
set multiplexer (_is_multiplexed)
switch $multiplexer
case screen
set pane (_get_screen_window)
case tmux
set pane (_get_tmux_window)
end
set_color 666666
if test -z $pane
echo -n ""
else
echo -n $pane' | '
end
end
function _get_tmux_window
tmux lsw | grep active | sed 's/\*.*$//g;s/: / /1' | awk '{ print $2 "-" $1 }' -
end
function _get_screen_window
set initial (screen -Q windows; screen -Q echo "")
set middle (echo $initial | sed 's/ /\n/g' | grep '\*' | sed 's/\*\$ / /g')
echo $middle | awk '{ print $2 "-" $1 }' -
end
function _is_multiplexed
set multiplexer ""
if test -z $TMUX
else
set multiplexer "tmux"
end
if test -z $WINDOW
else
set multiplexer "screen"
end
echo $multiplexer
end