summaryrefslogtreecommitdiff
path: root/shell/completion.bash
AgeCommit message (Collapse)Author
2025-01-28Enhance --min-height option to take number followed by +Junegunn Choi
2025-01-27[completion] Replace 'tr' with built-in string substitutionJunegunn Choi
2025-01-27Enhance click-header eventJunegunn Choi
* Expose the name of the mouse action as $FZF_KEY * Trigger click-header on mouse up * Enhanced clickable header for `kill` completion
2025-01-26[completion] Make kill completion header clickableJunegunn Choi
2024-10-15Use eval to evaluate $post variable as command. (#4023)Thomas Martitz
2024-09-23[bash] Fix infinite retry loop for completion setting without "-F func" (#4004)Koichi Murase
2024-08-22[bash] Revert skipping setting up fuzzy path completionJunegunn Choi
This partially reverts a2d0e8f not to break backward compatibility.
2024-08-11[bash] Enable fuzzy path completion for all commands (#3958)Junegunn Choi
All commands with no custom completion defined. Close #3957
2024-08-07fix: Add fallback for cygwin ps (#3955)Eduardo D Sanchez
2024-07-08[bash] Add code to the default list of programs to support completionJunegunn Choi
Close #3843
2024-07-06[completion] Use --wrap option in process completionJunegunn Choi
And remove the short preview window for showing the whole command. Because it is important to be able to see the whole command before deciding to kill it.
2024-06-03Add new options to bash completionJunegunn Choi
2024-05-09chore: Update flags to include long-form options for case (#3785)LangLangBart
2024-05-07[shell] Add $FZF_COMPLETION_{DIR,PATH}_OPTSJunegunn Choi
To allow separately overriding 'walker' options. Close #3778
2024-04-27[completion] Add undocumented bash variables for completion commandsJunegunn Choi
And allow empty FZF_COMPLETION_DIR_COMMANDS
2024-04-25Make completion.bash load fasterJunegunn Choi
* Reduce number of `__fzf_orig_completion < <(complete -p "$@" 2> /dev/null)`s * Clean up options in fzf completion * Remove telnet completion
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-04-04[bash] Add -o nospace to dir completion options (#1987)Junegunn Choi
2024-04-04[bash] Remove -o default from dir completion options (#1987)Junegunn Choi
2024-04-04[bash] Fix variable completion of directory-related commandsJunegunn Choi
Fix #1987
2024-03-29[bash-completion] Make dynamic loader return 124 to retry completionJunegunn Choi
Close #3702
2024-03-17[bash] Fix default completion of unset, unalias, etcJunegunn Choi
Fix #3679
2024-03-13Add walker options and replace 'find' with the built-in walker (#3649)Junegunn Choi
2024-03-13[bash] Fix regression in dynamic completionJunegunn Choi
Fix #3674
2024-03-10[bash] Update orig_complete after _completion_loaderKoichi Murase
2024-03-10[bash] Refactor access to "_fzf_orig_complete_${cmd//[^A-Za-z0-9_]/_}"Koichi Murase
In the current codebase, for the original completion settings, the pieces of the codes to determine the variable name and to access the stored data are scattered. In this patch, we define functions to access these variables. Those functions will be used in a coming patch. * This patch also resolves an inconsistent escaping of "$cmd": $cmd is escaped as ${...//[^A-Za-z0-9_]/_} in some places, but it is escaped as ${...//[^A-Za-z0-9_=]/_} in some other places. The latter leaves the character "=" in the command name, which causes an issue because "=" cannot be a part of a variable name. For example, the following test case produces an error message: $ COMP_WORDBREAKS=${COMP_WORDBREAKS//=} $ _test1() { COMPREPLY=(); } $ complete -vF _test1 cmd.v=1.0 $ _fzf_setup_completion path cmd.v=1.0 $ cmd.v=1.0 [TAB] bash: _fzf_orig_completion_cmd_v=1_0: invalid variable name The behavior of leaving "=" was present from the beginning when saving the original completion is introduced in commit 91401514, and this does not seem to be a specific reasoning. In this patch, we replace "=" as well as the other non-identifier characters. * Note: In this patch, the variable REPLY is used to return values from functions. This design is to make it useful with the value substitutions, a new Bash feature of the next release 5.3, which is taken from mksh.
2023-10-29[completion] Handle all hostaliases in /etc/hosts (#3495)akdevservices
* Fix #3488 * Handle inline comments in hosts file
2023-10-19[bash] Preserve existing completion for sshJunegunn Choi
Fix #3484
2023-10-13[bash] Remove implicit bash-completion dependencyJunegunn Choi
2023-10-12[bash] statically define __fzf_list_hosts() with either methodChristoph Anton Mitterer
When bash-completion (and thus `_known_hosts_real()`) is / is not available this will typically not change during the lifetime of a shell. The only exception is if the user would unset `_known_hosts_real()`, but well, that would be his problem. So we can easily define `__fzf_list_hosts()` either using `_known_hosts_real()` or using the old code, and avoid checking every time whether `_known_hosts_real()` is defined. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-10-12[bash] try to use bash-completions’s _known_hosts_real() for getting hostnamesChristoph Anton Mitterer
If defined, use bash-completions’s `_known_hosts_real()`-function to create the list of hostnames. This obviously requires bash-completion to be sourced before fzf. If not defined, fall back to the previous code. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-10-12[shell] make `__fzf_list_hosts()` definable by the userChristoph Anton Mitterer
Just like it’s already done for `_fzf_compgen_path()` and `_fzf_compgen_dir()` allow a user to easily define his own version of `__fzf_list_hosts()`. Also add some documentation on the expected “interface” of such custom function. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-10-12[shell] move username prefixing code where neededChristoph Anton Mitterer
`__fzf_list_hosts()` seems like a function a user may want to override with some custom code. For that reason it should be kept as simple as possible, that is printing only hostnames, one per line, optionally in some sorting. The handling of adding a `username@` (which is then the same for each line), if any, would unnecessarily complicate that for people who want to override the function. Therefore this commit moves that to the places where it's actually used (as of now only `_fzf_complete_ssh()`). This also saves any such handling for `_fzf_host_completion()`, where this isn’t needed at all. Right now it comes at a cost, namely an extra invocation of `awk` in the `_fzf_complete_ssh()`-case. However, it should be easily possible to improve `__fzf_list_hosts()` to no longer need the final `awk` in the pipeline there. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-10-12[shell] don’t print error on non-existent SSH filesChristoph Anton Mitterer
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
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-11[bash] bring fzf’s own bash completion up to date (#3471)Christoph Anton Mitterer
* [bash] bring fzf’s own bash completion up to date This orders and groups completed options and values in just as they appear in the code respectively, for some option values, as they’d be printed in the `--help`-output. It does not add support for completion of `:` right after values that support an optional `:some-further-value` postfix. Neither does it add support for the `--option=value`-style. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> * [bash] drop unnecessary code in handling `history` Presumably, the dropped code is not needed for any effect, thus drop it. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> --------- 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-04[shell] Avoid side-effects during eval (#3459)Junegunn Choi
Take two. * Avoid eval if the prefix contains `:=` * This is not to evaluate variable assignment. e.g. ${FOO:=BAR} * [zsh] Prevent `>(...)` form * Suppress error message from prefix evaluation * Stop completion when prefix evaluation failed Thanks to @calestyo
2023-10-02[bash] Don’t print function definition when checking for existence (#3448)Christoph Anton Mitterer
When just checking whether a function is already defined or not, it’s not necessary to print out it’s definition (should it be defined). bash’s `declare` provides the `-F`-option (which implies `-f`), which should give a minor performance improvement Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-10-02[completion] Prevent running a command during 'eval'Junegunn Choi
Do not attempt to provide fuzzy completion if the prefix contains a pattern that may start an arbitraty command. * $(...) * `...` * <(...) Close #3459
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-09-18Basic context-aware completion for ssh command (#3424)Timofei Bredov
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2023-04-01[shell] Update kill completionJunegunn Choi
* Explicitly specify the list of fields for consistent experience * Add fallback command for BusyBox (Close #3219) * Apply `--header-lines=1` to show the column header
2023-03-27Add bat to bash autocomplete commands (#3223)Sten Arthur Laane
Bat is a common alternative to cat, it's even referenced multiple times in fzf docs. This makes `bat **` work by default.
2023-02-12[bash] Enable environment variable completion for printenvJunegunn Choi
Close #3145
2023-01-23Add Helix editor to bash autocompletion (#3137)Nachum Barcohen
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-09-10[bash] Fix completion of var or alias containing newlines (#2952)knutze
* Fix bash completion var or aliase containing newlines * Support for various bash declare options Co-authored-by: knutze <shakte@gmail.com>
2022-08-22[completion] Remove extra trailing slash on directory completionJunegunn Choi
Fix #2931