From: Jon Schewe Date: Sun, 12 Feb 2012 18:14:48 +0000 (-0600) Subject: Add _filedir replacement X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=98c9bc16a3533d60780ebe852a723563ad78af97;p=common%2Fbash_it.git Add _filedir replacement Turns out that _filedir isn't always defined. So bring our own version in. --- diff --git a/completion/available/tmux.completion.bash b/completion/available/tmux.completion.bash index 1026078..ca06d83 100644 --- a/completion/available/tmux.completion.bash +++ b/completion/available/tmux.completion.bash @@ -3,6 +3,18 @@ # Usage: Put "source bash_completion_tmux.sh" into your .bashrc # Based upon the example at http://paste-it.appspot.com/Pj4mLycDE +_tmux_filedir () +{ + local IFS=' +'; + _expand || return 0; + if [ "$1" = -d ]; then + COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur )); + return 0; + fi; + COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" )) +} + function _tmux_complete_client() { local IFS=$'\n' local cur="${1}" @@ -38,7 +50,7 @@ _tmux() { prev="${COMP_WORDS[COMP_CWORD-1]}" if [ ${prev} == -f ]; then - _filedir + _tmux_filedir else # Search for the command local skip_next=0 @@ -121,7 +133,7 @@ _tmux() { -t) _tmux_complete_session "${cur}" ;; *) options="-t" ;; esac ;; - source-file|source) _filedir ;; + source-file|source) _tmux_filedir ;; has-session|has|kill-session) case "$prev" in -t) _tmux_complete_session "${cur}" ;;