Last active
January 26, 2017 18:25
-
-
Save cybic/6375457 to your computer and use it in GitHub Desktop.
Get tab-completion for the `tmux' command in bash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash completion for tmux | |
# Written by Oystein Steimler <[email protected]> | |
# | |
# $ sudo cp tmux-completion.bash /etc/bash_completion.d/tmux | |
# $ . /etc/bash_completion.d/tmux | |
# | |
_sessions() { | |
SESSIONS=`tmux ls -F#{session_name} | xargs echo` | |
} | |
_tmux() { | |
local cur prev comp | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
case "$prev" in | |
attach) | |
comp="-t" | |
;; | |
att) | |
comp="-t" | |
;; | |
new) | |
comp="-s" | |
;; | |
-t) | |
_sessions | |
comp="$SESSIONS" | |
;; | |
tmux) | |
comp="attach new ls list" | |
;; | |
esac | |
COMPREPLY=( $(compgen -W "${comp}" -- ${cur}) ) | |
return 0 | |
} | |
complete -F _tmux tmux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment