-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux-run-shell
executable file
·41 lines (39 loc) · 1.41 KB
/
tmux-run-shell
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
#!/bin/bash
# Breif:
# tmux run-shell action exec complicate command cause chaos.
# maybe is the command str contains some specail char like (`"'),
# it seems like the command would be cache.
#
########################################################################
#=> common libs
########################################################################
source "$HOME/CodeHub/SHELL/libs/bootstrap.sh"
case "$1" in
lastwindow)
tmux select-window -t `tmux list-windows | sed -n '$p' | awk -F ':' '{print $1}'`
;;
getactivewindow)
tmux list-windows | egrep -o ' \w+\* ' | tr -d '*'
;;
getwindowlist)
tmux lsw | sed 's/^/ /g' | percol --initial-index $(tmux lsw | awk '/ .+-/ {print NR-1}') \
| cut -d':' -f 1 | tr -d '\n' | xargs -0 tmux select-window -t
;;
getsessionlist)
tmux ls | sed 's/^/ /g' | percol --initial-index $(tmux ls | awk '/attached/ {print NR-1}') \
| cut -d':' -f 1 | tr -d '\n' | xargs -0 tmux switch-client -t
;;
getkeylist)
tmux list-keys | sed 's/^/ /g' | percol | xargs -i tmux kill-pane
;;
copy)
tmux save-buffer - | xsel -ib
;;
paste)
tmux set-buffer "$(xsel -ob)"; tmux paste-buffer
;;
clear)
xdotool set_window -name ' ' $(xdotool getactivewindow) && clear && tmux clear-history
;;
*) echo "NONE" ;;
esac