Skip to content

Commit

Permalink
fix(zsh): preserve multi whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
danztran committed Jan 4, 2024
1 parent 36bbaba commit 9d33367
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions shell/key-bindings.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ bindkey -M viins '\ec' fzf-cd-widget
fzf-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
selected=( $(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} ${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-z:ignore ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
selected="$(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} ${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-z:ignore ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m" $(__fzfcmd))"
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
num=$(awk '{print $1}' <<< "$selected")
if [[ "$num" =~ ^[0-9]+$ ]]; then
zle vi-fetch-history -n $num
else # selected is a custom query, not from history
LBUFFER="${selected[@]}"
LBUFFER="$selected"
fi
fi
zle reset-prompt
Expand Down

0 comments on commit 9d33367

Please sign in to comment.