Skip to content

Commit

Permalink
Don't autocomplete sessions if none are running
Browse files Browse the repository at this point in the history
  • Loading branch information
cwacek committed Sep 5, 2013
1 parent 9e73fd5 commit 668cc2a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tmux-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ _tmux()
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"

case $prev in
case $prev in
-t)
local sessions=$(tmux list-sessions 2>&1)
if [[ $? == 0 ]]; then
local sessions=$(tmux list-sessions 2>/dev/null | awk '{printf("%s ", $1)}')
if [[ -z $sessions ]]; then
COMPREPLY=()
else
COMPREPLY=( $(compgen -W "$(echo $sessions | awk -F ':' '{print $1}')" -- $cur) )
return 0
fi
return 0
;;
esac

Expand Down

0 comments on commit 668cc2a

Please sign in to comment.