Skip to content
Myr

Bind CTRL-/ and ALT-/ to toggle-wrap by default

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 8ff4e52 · Browse files · 7 files+18 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+18 added−16 removed

  • other:+18 added−16 removed

7 files+18 added−16 removed

modified:man/man1/fzf.1+1 added-1 removed
1495 unmodified lines
1496 \fBtoggle\-search\fR (toggle search functionality)1497 \fBtoggle\-sort\fR1498 \fBtoggle\-track\fR (toggle global tracking option (\fB\-\-track\fR))1499 \fBtoggle\-track\-current\fR (toggle tracking of the current item)1500 \fBtoggle\-wrap\fR1500 \fBtoggle\-wrap\fR \fIctrl\-/\fR \fIalt\-/\fR1501 \fBtoggle+up\fR \fIbtab (shift\-tab)\fR1502 \fBtrack\-current\fR (track the current item; automatically disabled if focus changes)1503 \fBtransform(...)\fR (transform states using the output of an external command)1504 \fBtransform\-border\-label(...)\fR (transform border label using an external command)
183 unmodified lines
modified:shell/key-bindings.bash+2 added-2 removed
modified:shell/key-bindings.fish+2 added-2 removed
70 unmodified lines
71 # history's -z flag was added in fish 2.4.0, so don't use it for versions72 # before 2.4.0.73 if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ];74 if type -P perl > /dev/null 2>&175 set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --highlight-line $FZF_CTRL_R_OPTS +m")75 set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")76 set -lx FZF_DEFAULT_OPTS_FILE ''77 builtin history -z --reverse | command perl -0 -pe 's/^/$.\t/g; s/\n/\n\t/gm' | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | command perl -pe 's/^\d*\t//' | read -lz result78 and commandline -- $result79 else80 set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "--scheme=history --bind=ctrl-r:toggle-sort --highlight-line $FZF_CTRL_R_OPTS +m")80 set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "--scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")81 set -lx FZF_DEFAULT_OPTS_FILE ''82 builtin history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result83 and commandline -- $result84 end
113 unmodified lines
modified:shell/key-bindings.zsh+2 added-2 removed
111 unmodified lines
112 # history lines, is loaded, and that Perl is installed for multi-line output.113 if zmodload -F zsh/parameter p:history 2>/dev/null && (( ${#commands[perl]} )); then114 selected="$(printf '%s\t%s\000' "${(kv)history[@]}" |115 perl -0 -ne 'if (!$seen{(/^\s*[0-9]+\**\t(.*)/s, $1)}++) { s/\n/\n\t/g; print; }' |116 FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \116 FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \117 FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"118 else119 selected="$(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |120 FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m") \120 FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m") \121 FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"122 fi123 local ret=$?124 if [ -n "$selected" ]; then
19 unmodified lines
modified:src/terminal.go+2 added
615 unmodified lines
616 add(tui.CtrlY, actYank)617 if !util.IsWindows() {618 add(tui.CtrlZ, actSigStop)619 }620 add(tui.CtrlSlash, actToggleWrap)621 addEvent(tui.AltKey('/'), actToggleWrap)622623 addEvent(tui.AltKey('b'), actBackwardWord)624 add(tui.ShiftLeft, actBackwardWord)625 addEvent(tui.AltKey('f'), actForwardWord)
4397 unmodified lines
modified:CHANGELOG.md+8 added-6 removed
5 unmodified lines
6- Implemented line wrap of long items7 - `--wrap` option enables line wrap8 - `--wrap-sign` customizes the sign for wrapped lines (default: `↳ `)9 - `toggle-wrap` action toggles line wrap10 ```sh11 history | fzf --tac --wrap --bind 'ctrl-/:toggle-wrap'1213 # You can press CTRL-/ to toggle line wrap in CTRL-R binding14 export FZF_CTRL_R_OPTS=$'--bind ctrl-/:toggle-wrap --wrap-sign "\t↳ "'15 ```10 ```sh11 history | fzf --tac --wrap --bind 'ctrl-/:toggle-wrap' --wrap-sign $'\t↳ '12 ```13 - fzf by default binds `CTRL-/` and `ALT-/` to `toggle-wrap`14- Updated shell integration scripts to leverage line wrap15 - CTRL-R binding includes `--wrap-sign $'\t↳ '` to indent wrapped lines16 - `kill **` completion uses `--wrap` to show the whole line by default17 instead of showing it in the preview window18- Added `--info-command` option for customizing the info line19 ```sh20 # Prepend the current cursor position in yellow21 fzf --info-command='echo -e "\x1b[33;1m$FZF_POS\x1b[m/$FZF_INFO 💛"'
2184 unmodified lines
modified:README.md+1 added-3 removed
462 unmodified lines
463 sourcing the script464- `CTRL-R` - Paste the selected command from history onto the command-line465 - If you want to see the commands in chronological order, press `CTRL-R`466 again which toggles sorting by relevance467 - Press `CTRL-/` or `ALT-/` to toggle line wrapping468 - Set `FZF_CTRL_R_OPTS` to pass additional options to fzf469 ```sh469 # CTRL-/ to toggle small preview window to see the full command470 # CTRL-Y to copy the command into clipboard using pbcopy471 export FZF_CTRL_R_OPTS="472 --preview 'echo {}' --preview-window up:3:hidden:wrap473 --bind 'ctrl-/:toggle-preview'472 --bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'473 --color header:italic474 --header 'Press CTRL-Y to copy command into clipboard'"475 ```
433 unmodified lines