diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c84630..78e7938c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ but it's often more useful when toggled dynamically with the `toggle-raw` action. ```sh -tree | fzf --reverse --bind ctrl-x:toggle-raw +tree | fzf --reverse --bind alt-r:toggle-raw ``` While non-matching items are displayed in a dimmed color, they are treated just @@ -56,7 +56,7 @@ option. ```sh # Use a thinner gutter instead of the default dashed line -fzf --bind ctrl-x:toggle-raw --gutter-raw ▎ +fzf --bind alt-r:toggle-raw --gutter-raw ▎ ``` ##### Color and style of non-matching items @@ -97,8 +97,7 @@ fzf --raw --bind 'enter:transform:[[ ${FZF_RAW-1} = 1 ]] && echo accept || echo #### Leveraging raw mode in shell integration -The `CTRL-R` binding (command history) now lets you toggle raw mode with -`CTRL-X`. +The `CTRL-R` binding (command history) now lets you toggle raw mode with `ALT-R`. ### Style changes diff --git a/README.md b/README.md index ac18723d..312a99c3 100644 --- a/README.md +++ b/README.md @@ -522,6 +522,9 @@ the following key bindings in bash, zsh, and fish. - `CTRL-R` - Paste the selected command from history onto the command-line - If you want to see the commands in chronological order, press `CTRL-R` again which toggles sorting by relevance + - Press `ALT-R` to toggle "raw" mode where you can see the surrounding items + of a match. In this mode, you can press `CTRL-N` and `CTRL-P` to move + between the matching items only. - Press `CTRL-/` or `ALT-/` to toggle line wrapping - Set `FZF_CTRL_R_OPTS` to pass additional options to fzf ```sh diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash index 0f6e25a3..b335e6de 100644 --- a/shell/key-bindings.bash +++ b/shell/key-bindings.bash @@ -81,7 +81,7 @@ if command -v perl > /dev/null; then set +o pipefail builtin fc -lnr -2147483648 | last_hist=$(HISTTIMEFORMAT='' builtin history 1) command perl -n -l0 -e "$script" | - FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-x:toggle-raw --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \ + FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) --query "$READLINE_LINE" ) || return READLINE_LINE=$(command perl -pe 's/^\d*\t//' <<< "$output") @@ -104,7 +104,7 @@ else # awk - fallback for POSIX systems set +o pipefail builtin fc -lnr -2147483648 2> /dev/null | # ( $'\t '$'\n' )* ; ::= [^\n]* ( $'\n' )* __fzf_exec_awk "$script" | # ( $'\t'$'\000' )* - FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-x:toggle-raw --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \ + FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) --query "$READLINE_LINE" ) || return READLINE_LINE=${output#*$'\t'} diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 3ca8447f..1bebaf30 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -159,7 +159,7 @@ function fzf_key_bindings set -lx FZF_DEFAULT_OPTS (__fzf_defaults '' \ '--nth=2..,.. --scheme=history --multi --wrap-sign="\t↳ "' \ '--bind=\'shift-delete:execute-silent(eval history delete --exact --case-sensitive -- (string escape -n -- {+} | string replace -r -a "^\d*\\\\\\t|(?<=\\\\\\n)\\\\\\t" ""))+reload(eval $FZF_DEFAULT_COMMAND)\'' \ - "--bind=ctrl-r:toggle-sort,ctrl-x:toggle-raw --highlight-line $FZF_CTRL_R_OPTS" \ + "--bind=ctrl-r:toggle-sort,alt-r:toggle-raw --highlight-line $FZF_CTRL_R_OPTS" \ '--accept-nth=2.. --read0 --print0 --with-shell='(status fish-path)\\ -c) set -lx FZF_DEFAULT_OPTS_FILE diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index 12af22a6..15fb5ef0 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -132,11 +132,11 @@ fzf-history-widget() { if zmodload -F zsh/parameter p:{commands,history} 2>/dev/null && (( ${+commands[perl]} )); then selected="$(printf '%s\t%s\000' "${(kv)history[@]}" | perl -0 -ne 'if (!$seen{(/^\s*[0-9]+\**\t(.*)/s, $1)}++) { s/\n/\n\t/g; print; }' | - FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-x:toggle-raw --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \ + FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))" else selected="$(fc -rl 1 | __fzf_exec_awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' | - FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-x:toggle-raw --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m") \ + FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,alt-r:toggle-raw --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m") \ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))" fi local ret=$?