Created
April 30, 2024 15:00
-
-
Save kunalb/0d875345f6201a8785bef0ef4e6450f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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