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 ++++++++++++++++++++++++++++++++++ _zsh/90-aliases.zsh | 6 ------ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 _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: # diff --git a/_zsh/90-aliases.zsh b/_zsh/90-aliases.zsh index 1327721..a530fba 100644 --- a/_zsh/90-aliases.zsh +++ b/_zsh/90-aliases.zsh @@ -22,10 +22,4 @@ alias lsa='ls -lah' alias grep='grep --color=auto' -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