Skip to content

Instantly share code, notes, and snippets.

@kunalb
Created April 30, 2024 15:00
Show Gist options
  • Save kunalb/0d875345f6201a8785bef0ef4e6450f9 to your computer and use it in GitHub Desktop.
Save kunalb/0d875345f6201a8785bef0ef4e6450f9 to your computer and use it in GitHub Desktop.
_tmux_pane_words() {
local current_word="${${=LBUFFER}[-1]}"
local prompt="${LBUFFER% *} ␣ $RBUFFER "
local selected_word=$(tmux capture-pane -p -J -S 0 -E - | tr ' ' '\n' | sort -u | rg '[a-zA-Z0-9]+' | fzf --select-1 --exit-0 --query="$current_word" --prompt="$prompt" --height=20 --layout=reverse)
if [[ -n $selected_word ]]; then
BUFFER="${LBUFFER% *} $selected_word$RBUFFER"
fi
zle redisplay
}
zle -N _tmux_pane_words
bindkey '^U' _tmux_pane_words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment