From b0f791221329cf56d62c063f16922901dde8091e Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 2 May 2016 15:12:26 +0800 Subject: _zsh: add 80-tmux.zsh with "percol" integration --- _zsh/80-tmux.zsh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 _zsh/80-tmux.zsh (limited to '_zsh/80-tmux.zsh') diff --git a/_zsh/80-tmux.zsh b/_zsh/80-tmux.zsh new file mode 100644 index 0000000..ae0f1c5 --- /dev/null +++ b/_zsh/80-tmux.zsh @@ -0,0 +1,34 @@ +# +# zsh/tmux.zsh +# + + +# Integrate `tmux` attach with `percol` +# Credit: https://github.com/mooz/percol +if exists percol; then + function tmattach() { + if [[ $1 == "" ]]; then + PERCOL=percol + else + PERCOL="percol --query $1" + fi + + sessions=$(tmux list-sessions) + [ $? -ne 0 ] && return + + session=$(echo ${sessions} | eval ${PERCOL} | cut -d: -f1) + if [[ -n "${session}" ]]; then + tmux attach -t ${session} + fi + } +fi + + +alias ta='tmux attach -t' +alias tl='tmux list-sessions' +alias ts='tmux new-session -s' +alias tkss='tmux kill-session -t' +alias tksv='tmux kill-server' + + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: # -- cgit v1.2.2