Add gpgwkd function for gpg key fetches
[zsh.git] / .zsh / external / zaw / sources / tmux.zsh
1 # -*- mode:sh -*-
2 #
3 # zaw-src-tmux
4 #
5 # select tmux session and attach it
6 #
7
8 function zaw-src-tmux() {
9 local session state
10
11 tmux list-sessions | \
12 while read session state; do
13 candidates+=("${session}")
14 cand_descriptions+=("${(r:30:::::)session} ${state}")
15 done
16 actions=('zaw-callback-tmux-attach')
17 act_descriptions=('attach session')
18 actions+=('zaw-callback-tmux-kill')
19 act_descriptions+=('kill session')
20 }
21
22 zaw-register-src -n tmux zaw-src-tmux
23
24 function zaw-callback-tmux-attach() {
25 if [ -z $TMUX ]; then
26 BUFFER="tmux attach -t ${(q)1}"
27 else
28 BUFFER="tmux switch-client -t ${(q)1}"
29 fi
30 zle accept-line
31 }
32
33 function zaw-callback-tmux-kill() {
34 BUFFER="tmux kill-session -t ${(q)1}"
35 zle accept-line
36 }