summaryrefslogtreecommitdiff
path: root/shell/key-bindings.bash
AgeCommit message (Collapse)Author
2025-10-12feat: Allow disabling Ctrl-R binding in shell integration (#4535)Jacobo de Vera
Close #4417
2025-10-09CTRL-R: Bind ALT-R to toggle-rawJunegunn Choi
2025-10-09Add '--bind ctrl-x:toggle-raw' to CTRL-R bindingsJunegunn Choi
2025-09-24Apply shfmt to bash script files (make fmt)Junegunn Choi
2025-09-24make lint: Perform bash script lintingJunegunn Choi
2025-08-19[bash 3] Fix CTRL-T and ALT-C to preserve the last yank (#4496)xty
2025-07-25fix(shell): check for mawk existence before version check (#4468)LangLangBart
close #4463
2025-06-08[bash,zsh] Separate common functions into "shell/common.sh"Koichi Murase
2025-06-08[bash,zsh] Work around Solaris awk, which is non-standardKoichi Murase
Solaris awk at /usr/bin/awk is meant for backward compatibility with an ancient implementation of 1977 awk in the original UNIX. It lacks many features of POSIX awk. To use a standard-conforming version in Solaris, one needs to explicitly use /usr/xpg4/bin/awk.
2025-06-08[bash,zsh] Work around a quirk of macOS awkKoichi Murase
macOS awk is a variant of nawk, but it contains a unique patch for the UTF-8 support. However, this patch causes the problem. If the input contains any non-UTF-8 data, macOS awk stops processing and does not do anything, instead of ignoring the unrecognized data and continue the processing. However, the contents of the ssh configuration and /etc/hosts is not under the control of fzf, so we cannot fix the input when those files contain non-UTF-8 data. To work around this behavior, one can set the locale to LC_ALL=C to treat the input data with the plain 8-bit encoding.
2025-01-28Enhance --min-height option to take number followed by +Junegunn Choi
2024-07-08Bind CTRL-/ and ALT-/ to toggle-wrap by defaultJunegunn Choi
2024-05-31[bash] Indent multi-line history entriesJunegunn Choi
2024-05-29[shell] Add --highlight-line to CTRL-R bindingsJunegunn Choi
2024-04-19Respect $FZF_DEFAULT_OPTS_FILE in key bindings and completion (#3742)Junegunn Choi
Fix #3740
2024-04-10[shell] Revert interactiveness checks for evalJunegunn Choi
So that there's no error even when the scripts are mistakenly evaluated in non-interactive sessions. bash -c 'eval "$(fzf --bash)"; echo done' zsh -c 'eval "$(fzf --zsh)"; echo done' * https://github.com/junegunn/fzf/pull/3675#issuecomment-2044860901 * https://github.com/junegunn/fzf/commit/f103aa4753b435f8f45c5130323effeb75583c15
2024-03-31[shell] Make ALT-C use the absolute path to the selected directory (#3688)Emilio Vesprini
Rationale: this way the resulting cd command that ends up in the shell history can be reused to get to the same location regardless of the current working directory. Co-authored-by: LangLangBart <92653266+LangLangBart@users.noreply.github.com>
2024-03-17Make it possible to disable `Ctrl+T` / `Alt+C` / completions (#3678)Eli Barzilay
This makes it possible to skip one of the above key bindings or completions by setting a variable to an empty string. For example, FZF_CTRL_T_COMMAND= FZF_ALT_C_COMMAND= \ eval "$(fzf --zsh)" Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2024-03-13Add walker options and replace 'find' with the built-in walker (#3649)Junegunn Choi
2023-10-11[bash] Use `command` to “protect” further commands (#3462)Christoph Anton Mitterer
This commit causes all simple commands that are not built-ins or functions to be invoked via `command` in order to protect them from alias substitution or from accidentally taking functions of the same name. It was decided to not “protect” `fzf` and `fzf-tmux` for now. Maybe a better solution should be implemented for that in the future. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-10-09Improve interactiveness checks (#3449)Christoph Anton Mitterer
* [bash] return instead of not executing an if-block, when non-interactive This should keep the code more readable, be less error prone (accidentally doing something outside the if-block and aligns the code with what’s already done for zsh. `0` is returned, because it shall not be considered an error when the script is (accidentally) sourced from a non-interactive shell. If executed as a script (rather than sourced), the results are not specified by POSIX but depend on the shell, with bash giving an error in that case. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> * [shell] exit immediately when called from non-interactive shell The shell execution environment shouldn’t be modified at all, when called from a non-interactive shell. It shall be noted that the current check may become error prone for bash, namely in case there should ever be a differentiation between `i` and `I` in the special variable `-` and bash’s `nocasematch`-shell-option be used. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-10-07[bash] Improve mawk detection (#3463)step
* Use the all-compatible mawk `-W version` option. https://github.com/junegunn/fzf/pull/3313#issuecomment-1747934690. * Run the command and not a function consistently with #3462. The version check bash code relies on the following mawk source code, extracted from mawk 1.3.4 20230322. ``` version.c: 18- #include "init.h" 19- #include "patchlev.h" 20- 21: #define VERSION_STRING \ 22- "mawk %d.%d%s %s\n\ 23- Copyright 2008-2022,2023, Thomas E. Dickey\n\ 24- Copyright 1991-1996,2014, Michael D. Brennan\n\n" .... 30- void 31- print_version(FILE *fp) 32- { 33: fprintf(fp, VERSION_STRING, PATCH_BASE, PATCH_LEVEL, PATCH_STRING, DATE_STRING); 34- fflush(fp); 35- 36- #define SHOW_RANDOM "random-funcs:" patchlev.h: 13- /* 14- * $MawkId: patchlev.h,v 1.128 2023/03/23 00:23:57 tom Exp $ 15- */ 16: #define PATCH_BASE 1 17- #define PATCH_LEVEL 3 18- #define PATCH_STRING ".4" 19- #define DATE_STRING "20230322" ``` Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2023-09-27[bash] CTRL-R on bash 3: Use backticks to avoid delayJunegunn Choi
https://github.com/junegunn/fzf/commit/e0b29e437be458066fca4dab39b282dfc11466f6
2023-09-24[shell] don’t needlessly escape `.` in shell patternChristoph Anton Mitterer
`find`’s `-path`-option is described to use shell patterns (i.e. POSIX’ pattern matching notation). In that, `.` is not a special character, thus escaping it shouldn’t be necessary. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-09-22[bash] History, use perl if installed otherwise awk (#3313)step
While awk is POSIX, perl isn't pre-installed on all *nix flavors. This commit eliminates the mandatory dependency on perl by using awk when perl is not available. Related: #3295, #3309, #3310. Test suite passed: * `make error` all test sections 'PASS' * `make docker-test` 215 runs, 1884 assertions, 0 failures, 0 errors, 0 skips. Manually tested in the following environments: * Linux amd64 with bash 3.2, 4.4, 5.2; gawk -P, one true awk, mawk, busybox awk. * macOS Catalina, bash 3.2, macOS awk 20070501. **Performance comparison:** Mawk turned out the fastest, then perl. One true awk's implementation should be the closest to macOS awk. Test data: 230 KB history, 15102 entries, including multi-line and duplicates. Linux, bash 4.4. Times in milliseconds. | Command | Mean | Min | Max | Relative | | :--- | ---: | ---: | ---: | -------: | | `mawk 1.3.4` | 22.9 | 22.3 | 25.6 | **1.00** | | `perl 5.26.1` | 34.3 | 33.6 | 35.1 | 1.49 | | `one true awk 20221215` | 41.9 | 40.6 | 46.3 | 1.83 | | `gawk 5.1.0` | 46.1 | 44.4 | 50.3 | 2.01 | | `busybox awk 1.27.0` | 64.8 | 63.2 | 70.0 | 2.82 | **Other Notes** A bug affects bash, which fails restoring a saved multi-line history entry as a single entry. Bug fixed in version 5.0.[^1] While developing this PR I discovered two unsubmitted issues affecting the current perl script. The output stream ends with `$'\n\0000'` instead of `$'\0000'`. Because of this, the script does not deduplicate a duplicated entry located at the end of the history list; therefore fzf displays two identical (not necessarily adjacent) entries. A minor point about the first issue is that the top fzf entry ends with a dangling line feed symbol, which is visible in the terminal. [^1]: https://github.com/bminor/bash/blob/ec8113b9861375e4e17b3307372569d429dec814/CHANGES#L1511 To enable: `shopt -s cmdhist lithist; HISTTIMEFORMAT='%F %T '`.
2023-09-19[shell] Use --scheme=path when appropriateJunegunn Choi
Without the option, you may get suboptimal results if you have many paths with spaces in their names. e.g. https://github.com/junegunn/fzf/issues/2909#issuecomment-1207690770 Close #3433
2023-08-18[bash] Disable pipefail in command substitutionJunegunn Choi
Fix #3382
2022-10-16[shell] Make bash/zsh completion and bindings work with 'set -u' (#2999)John Fred Fadrigalan
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2022-08-28Add --scheme=[default|path|history] option to choose scoring schemeJunegunn Choi
Close #2909 Close #2930
2022-04-29[bash] Make complex commands slightly more friendly to work with (#2784)Jan Warchoł
- extract logical parts to separate variables (e.g. $opts) - put options in $opts in similar order - move +/-m into $opts (at the end, so they won't be overridden) - split pipelines into multiple lines - remove "echo" that seems to be redundant All this should help with readability and also result in cleaner diffs when changes are made.
2022-04-22[shell] ALT-C: Use builtin cd to avoid conflicts (#2799)Ajeet D'Souza
2022-04-06[bash] Allow passing args to __fzf_select__ via fzf-file-widget (#2783)Jan Warchoł
This makes it easier to make customizations, for example instead of bind -x '"\C-o\C-i": FZF_CTRL_T_COMMAND="fasd -Rl" FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --tiebreak=index " fzf-file-widget' it's enough to just bind -x '"\C-o\C-i": FZF_CTRL_T_COMMAND="fasd -Rl" fzf-file-widget --tiebreak=index'
2021-11-19[shell] Use cd -- (#2659)zsugabubus
Otherwise directories starting with '-' may treated as options.
2021-08-15use proper bash-style notationa1346054
2021-01-01[shell] Disable CTRL-ZJunegunn Choi
Fix #2289
2020-04-03[fzf-tmux] Fall back to plain fzf when split failedJunegunn Choi
2020-04-03[fzf-tmux] Add option to start fzf in tmux popup windowJunegunn Choi
Requires latest tmux built from source (e.g. brew install tmux --HEAD) Examples: # 50%/50% width and height on the center of the screen fzf-tmux -p # 80%/80% fzf-tmux -p80% # 80%/40% fzf-tmux -p80%,40% # Separate -w and -h fzf-tmux -w80% -h40% # 80%/40% at position (0, 0) fzf-tmux -w80% -h40% -x0 -y0 You can configure key bindings and fuzzy completion to open in tmux popup window like so: FZF_TMUX_OPTS='-p 80%'
2020-03-29[shell] Update CTRL-R to remove duplicate commandsJunegunn Choi
Close #1940 Related: #1363 #749 #270 #49 #88 #492 #600
2020-03-13[bash] Restore --nth option in CTRL-RJunegunn Choi
2020-02-29[bash] Fix --query argument of CTRL-RJunegunn Choi
Fix #1898
2020-02-28[bash] Start C-r search with current command line (#1886)Jack Bates
Restore the original line when search is aborted. Add --query "$READLINE_LINE" and fall back to the current behavior pre Bash 4. Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2020-02-24[bash] Multiline C-r without histexpand (#1837)Jack Bates
Close #1370 Parses the history list, converts it to a NUL-delimited list of possibly multiline entries. Adds the fzf --read0 option. Works with and without histexpand enabled. Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2020-02-23[bash] Restore insertion point pre Bash 4 (#1881)Jack Bates
Make C-t more consistent pre and post Bash 4. It already kills the command line separately before and after the insertion point. Add set-mark and exchange-point-and-mark to restore the insertion point after yanking back and apply the same behavior to M-c. * CTRL-T should put extra space after pasted items Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2020-02-21[bash] Put C-t items at point in vi mode (#1876)Jack Bates
Be consistent with emacs mode and put the items at the point vs. the end of the command line.
2020-01-08[bash] Populate emacs and vi keymaps (#1815)Jack Bates
Enables the right bindings when switching between editing modes.
2019-06-03[bash] Make sure to execute builtin historyJunegunn Choi
Fix #1592
2018-04-25[bash] Add --sync to the default CTRL-R optionsJunegunn Choi
This compensates the use of --tac. fzf will not render on the screen until the complete list of commands are loaded.
2018-02-16[bash] Fix CTRL-R to preserve the latest yankJunegunn Choi
Close #1216 1. Append a single space so that step 3 won't fail 2. CTRL-E to move to the end of the line 3. CTRL-U to delete the whole line before the cursor 4. CTRL-Y to paste the deleted line 5. ESC+Y to rotate the kill ring and bring back the previous yank before step 3 6. CTRL-U to delete the whole line again 7. Paste `__fzf_history__` 8. ESC+CTRL-E to expand the command substitution 9. ESC+R to redraw the line 10. ESC+^ to expand the history entry (!NUMBER)
2017-12-07[bash] Trigger redraw-current-line before history-expand-lineJunegunn Choi
Close #681
2017-03-03[shell] Enable sorting by default in CTRL-RJunegunn Choi
CTRL-R binding used to start with --no-sort to list the matched commands in chronological order. However, it has been a constant source of confusion. Let's enable it by default from now on. The sorted result shouldn't be too confusing as we use --tiebreak=index.