From f183ed66c85f26670c5e148e952a6cb3f9a73cfd Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 26 Jul 2017 14:55:03 +0000 Subject: 41467: Correct completion of 'tmux new '. Reference: window_pane_spawn() in tmux 2.5. Also, document _cmdstring and _precommand. --- Completion/Unix/Command/_tmux | 2 +- Completion/Unix/Type/_cmdambivalent | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Completion/Unix/Type/_cmdambivalent (limited to 'Completion') diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index 0917da604..5f5bea922 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -526,7 +526,7 @@ _tmux-new-session() { '-t+[specify target session]:session:__tmux-sessions' \ '-x[specify width]:width' \ '-y[specify height]:height' \ - '*:: :_cmdstring' + '*:: :_cmdambivalent' } _tmux-new-window() { diff --git a/Completion/Unix/Type/_cmdambivalent b/Completion/Unix/Type/_cmdambivalent new file mode 100644 index 000000000..1f15d11ab --- /dev/null +++ b/Completion/Unix/Type/_cmdambivalent @@ -0,0 +1,17 @@ +#autoload + +if (( CURRENT == 1 && ${#words} == 1 )); then + # Heuristics to decide whether to complete for system() or for execl(). + local space=' ' + if (( ${${words[CURRENT]}[(I)$space]} )); then + _cmdstring + elif [[ ${${compstate[all_quotes]}[1]} == (\'|\") ]]; then + _cmdstring + else + _command_names -e + fi +elif (( CURRENT == 1 )); then + _command_names -e +else + _normal +fi -- cgit 1.4.1