Skip to content

Instantly share code, notes, and snippets.

@skanev
Created February 1, 2012 09:41
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skanev/1716179 to your computer and use it in GitHub Desktop.
Save skanev/1716179 to your computer and use it in GitHub Desktop.
zsh: autocomplete words in current tmux session
# Autocomplete from current tmux screen buffer
_tmux_pane_words() {
local expl
local -a w
if [[ -z "$TMUX_PANE" ]]; then
_message "not running inside tmux!"
return 1
fi
w=( ${(u)=$(tmux capture-pane \; show-buffer \; delete-buffer)} )
_wanted values expl 'words from current tmux pane' compadd -a w
}
zle -C tmux-pane-words-prefix complete-word _generic
zle -C tmux-pane-words-anywhere complete-word _generic
bindkey '^Xt' tmux-pane-words-prefix
bindkey '^X^X' tmux-pane-words-anywhere
zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' completer _tmux_pane_words
zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' ignore-line current
zstyle ':completion:tmux-pane-words-anywhere:*' matcher-list 'b:=* m:{A-Za-z}={a-zA-Z}'
@siers
Copy link

siers commented Feb 2, 2018

I'm wondering, why not just tmux capture-pane p instead capture; show; delete?

@imarko
Copy link

imarko commented Feb 7, 2018

@siers judging from the timestamp this gist predates capture-pane -p

there is also https://gist.github.com/blueyed/6856354 seems a bit more up to date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment