-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtmux-menu.sh
executable file
·62 lines (51 loc) · 967 Bytes
/
tmux-menu.sh
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
55
56
57
58
59
60
61
#!/usr/bin/env fish
function load_env
for f in .env/bin/activate.fish my.fish-env
if test -f $f
source $f
end
end
end
function cat_menu
for f in ~/.vim/tmux-menu.txt my.tmux-menu
if test -f $f
cat $f
end
end
end
function choose_command
cat_menu | fzf --no-sort --layout=reverse --prompt='Command: '
end
function set_title
set title (echo $argv[1] | awk 'BEGIN{FS="::"}{print $1}' | sed 's/ *$//')
if test -n "$TMUX"
tmux rename-window $title
end
end
function run_command
set cmd (echo $argv[1] | awk 'BEGIN{FS=":: "}{print $2}')
if test -n $cmd
if test -d $cmd
fish -C "cd $cmd"
else
eval $cmd
end
set s $status
if test $s -ne 0
echo "==== Command terminated with exit code $s ==="
read -s -P ""
end
end
end
function main
load_env
if test "$argv[1]" = "-t"
tmux rename-window "Run..."
end
set cmd (choose_command)
if test "$argv[1]" = "-t"
set_title $cmd
end
run_command $cmd
end
main $argv[1]