Commit Graph

225 Commits (c79c306adb40b50756481e1667fcf523de07a7b3)

Author SHA1 Message Date
Junegunn Choi c387689d1c
[shell] Enable sorting by default in CTRL-R
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.
8 years ago
Junegunn Choi 3a6af27586
[zsh] emulate -L zsh to avoid issues with incompatible options
Close #858
8 years ago
Junegunn Choi 11407bf656
Exclude sysfs in find commands 8 years ago
Pierre Neidhardt ce43ea9f42 [shell] Replace `sed` with `-mindepth 1` and `cut` (#844) 8 years ago
Daniel Gray afa25d8c57 [zsh] Do not cd when cancelling alt+c keybind (#840) 8 years ago
Junegunn Choi 95c77bfb98
Use --bind instead of --toggle-sort
Related #822
8 years ago
Junegunn Choi dbddee9de9
[fish] Add toggle-sort back to CTRL-R (#759) 8 years ago
Junegunn Choi d09ad13208
[zsh] Workaround trailing esacped space bug in go-shellwords
https://github.com/mattn/go-shellwords/issues/3

Close #812
8 years ago
Junegunn Choi 8ac37d5927
[shell] Do not override --reverse in CTRL-R
Close #807
8 years ago
Junegunn Choi 7ef0e50507
[bash/zsh] Remove unused --reverse in CTRL-R binding
Related #807
8 years ago
Junegunn Choi 44d3faa048
[completion] Restore --height option for kill completion 8 years ago
Junegunn Choi 208d4f2173
[shell] Make layout configurable via $FZF_DEFAULT_OPTS and $FZF_{KEY}_OPTS 8 years ago
Junegunn Choi dc3957ce79
[completion] Add preview window to kill completion 8 years ago
Junegunn Choi 4ecb7f3a16
Replace --normalize with --literal and enable normalization by default
Ref #790
8 years ago
Junegunn Choi 5b68027bee
Fix $FZF_COMPLETION_OPTS evaluation
Close #799
8 years ago
Junegunn Choi 1448d631a7
Add --height option 8 years ago
Junegunn Choi fd137a9e87
[bash/zsh-completion] Filter ~/.ssh/known_hosts
Close #791
8 years ago
Junegunn Choi 45faad7e04
[bash] Addendum fix for #580 8 years ago
Junegunn Choi 73eacf1137
[bash-completion] Always backup existing completion definitions
_fzf_completion_loaded is no longer checked. This change increases the
load time by a few milliseconds, but I can't think of a better way to
handle the issue.

Close #783.
8 years ago
Pierre Neidhardt c7b0764002 [shell] Use '-mindepth 1' to omit root folder in 'find' output (#779)
This removes the need for the 'sed' call. Faster, cleaner.
8 years ago
Pierre Neidhardt 0508e70f9b Overhaul fish functions (#759)
Replace the "temp file" workaround with the "read" function: it's
simpler and faster.

Use proper escaping, remove the custom function.

The "file" widget uses last token as root for the "find" command.
This replaces the equivalent of '**' completion in bash/zsh.
The "$dir" non-expanded variable can be used in FZF_CTRL_T_COMMAND to
set the root.
8 years ago
Junegunn Choi c49e65d926
[shell] Fix pruning condition of find command for CTRL-T and ALT-C
`-fstype dev` is invalid. It's devfs on macOS and devtmpfs on Linux.
8 years ago
Niraj Thapaliya d3da310b92 Use `command` to ignore shell function 8 years ago
Niraj Thapaliya 93e0a6a9de Gnu `[` evaluates both sides of a -o condition regardless
It doesn't short circuit like we expect, causing trouble when $dir is
empty

Use shell builtin instead
8 years ago
Pierre Neidhardt 2134c0c8a9 key-bindings.fish: Yank commandline in fzf-history-widget 8 years ago
Maverick Woo 2c8479a7c5 Fix #668
Handle uppercase letters in program names. This also deals with `-` and
`.`, both of which are quite common in program names, e.g., `xdg-open`
and `foo.sh`.
8 years ago
Tobias Frilling 639de4c27b Split default zsh binding at the correct place
The command substitution and following word splitting to determine the default
zle widget for ^I formerly only works if the IFS parameter contains a space. Now
it specifically splits at spaces, regardless of IFS.
8 years ago
Junegunn Choi 6a52f8b8dd
[zsh-completion] setopt localoptions noksh_arrays
Close #607
8 years ago
Junegunn Choi c36413fdf6
[zsh] Suppress error message when pipefail is not supported
Close #615
8 years ago
Junegunn Choi 3a4e053af7
[bash] Fall back to send-keys if named paste buffer is not supported
Related: #616
8 years ago
Sean b36b0a91f5 use tmux buffers for sending output to preserve character encoding 8 years ago
Junegunn Choi 6081eac58a
[shell] Suppress alias/function expansion
Close #611
8 years ago
Sebastian Reuße fed5e5d5af [zsh] Re-initialize zle when widgets finish
zle automatically calls zle-line-init when it starts to read a new line. Many
Zsh setups use this hook to set the terminal into application mode, since this
will then allow defining keybinds based on the $terminfo variable (the escape
codes in said variable are only valid in application mode).

However, fzf resets the terminal into raw mode, rendering $terminfo values
invalid once the widget has finished. Accordingly, keyboard bindings defined
via $terminfo won’t work anymore.

This fixes the issue by calling zle-line-init when widgets finish. Care is taken
to not call this widget when it is undefined.

Fixes #279
8 years ago
Daniel Hahler 38a2076b89 zsh: pass through exit code from widgets
This allows to have a custom widget like the following, which would
additionally accept the line, but only in case of entries being
selected:

    fzf-file-widget-with-accept() {
      zle fzf-file-widget
      if [[ "$?" == 0 ]] && (( $#BUFFER )); then
        zle accept-line
      fi
    }
    zle     -N   fzf-file-widget-with-accept
    bindkey '\e^T' fzf-file-widget-with-accept

With this `<C-a>t` will launch fzf, and simulate the pressing of "Enter"
afterwards.
8 years ago
Junegunn Choi c39c039e15
[shell] Add $FZF_CTRL_T_OPTS and $FZF_ALT_C_OPTS
Close #596
8 years ago
Aleks Kamko 19339e3a6d optimize fzf_default_completion binding 8 years ago
Junegunn Choi 95b34de339
[bash/zsh] Fix $FZF_CTRL_R_OPTS with option values with spaces 8 years ago
Junegunn Choi 923feb69ab
[zsh] Fix indentation 8 years ago
Jim Howell b8a3ba16a2
[bash/zsh] Take SSH completion hints from known_hosts
Signed-off-by: Junegunn Choi <junegunn.c@gmail.com>
8 years ago
Junegunn Choi e0b29e437b
[bash] Use backticks to avoid delay with blink-matching-paren
Close #580
8 years ago
Junegunn Choi bdb94fba7d
[zsh] Fix #579 - Locally unset globsubst 8 years ago
Junegunn Choi 988c9bd9be [zsh] Fix issues with unicode characters 8 years ago
Junegunn Choi d86cee2a69 [bash] Export fzf-file-widget function for bash 4+ (#546)
e.g. Remapping fzf-file-widget to CTRL-X CTRL-T intead of CTRL-T

    bind -x '"\C-x\C-t": fzf-file-widget'
    bind '"\C-t": transpose-chars'
9 years ago
Junegunn Choi e986f20a85 [fish] Use consistent function names for key bindings (#546)
- fzf-file-widget
- fzf-history-widget
- fzf-cd-widget
9 years ago
Junegunn Choi 772fa42dcb [fish] Fix intermittent errors on CTRL-T
Related: 23244bb
9 years ago
Junegunn Choi c3aa836ec0 [bash] Update completion.bash
[bash] Update completion.bash
9 years ago
Gene Pavlovsky 63dbf48546 Update key-bindings.bash
Faster startup. Use internal bash globbing instead of external grep binary (adapter from Gentoo's `/etc/bash/bashrc` TERM checking). Insignificant on Linux, but on Cygwin this cuts startup time by 40 ms on my Core i7 laptop.
9 years ago
Gene Pavlovsky e2401350a3 Update completion.bash
Fixes #548. Avoid using a subshell in _fzf_defc().
9 years ago
William Chargin 12230f8043 Fix bash-vimode normal-mode cd completion 9 years ago
William Chargin 0c8de1ca44 Fix Bash+vimode pre-launch delay
Summary:
Fix adapted from [@adamheins: fzf, vi-mode, and fixing delays][1].

  [1]: https://adamheins.com/blog/fzf-vi-mode-and-fixing-delays

The basic problem is that
fzf presses <Esc> to enter vi-movement-mode
(as opposed to insert mode)
and then presses a bunch of keys to set up the buffer.
But the <Esc> keypress is also the prefix for a bunch of other commands,
so Bash will dutifully wait an excruciating half-second
before actually executing this command.
Instead, we bind <C-x><C-a>, which is unused by default
and seems reasonably unlikely to be custom-bound,
to be another way to enter vi-movement-mode;
this binding is unambiguous, so fzf can use it without delay.

This change was made by just `:s/\\e/\\C-x\\C-a/gc`
in the relevant section,
after adding the actual binding and comment at the top.
9 years ago
Junegunn Choi 935e986be5 [zsh] Remove unnecessary evals 9 years ago
Junegunn Choi 24f3ec7f33 Fix FZF_CTRL_R_OPTS for zsh (#526) 9 years ago
Junegunn Choi a57b375b41 Add $FZF_CTRL_R_OPTS for overriding the default options for CTRL-R
Close #526
9 years ago
Junegunn Choi 09a2ab39fe [bash] Fix shellcheck warnings
Close #516
9 years ago
Junegunn Choi 26b9100709 Minor code cleanup 9 years ago
Junegunn Choi a568120e42 Fix #494 - _fzf_complete hangs on zsh when not using tmux pane 9 years ago
Junegunn Choi 40d934e378 0.11.3 9 years ago
Junegunn Choi 82067463b8 [completion] _fzf_complete_COMMAND_post for post processing
e.g.

_fzf_complete_foo() {
  _fzf_complete "--multi --reverse --header-lines=3" "$@" < <(
    ls -al
  )
}

_fzf_complete_foo_post() {
  awk '{print $NF}'
}

[ -n "$BASH" ] && complete -F _fzf_complete_foo -o default -o bashdefault foo
9 years ago
Junegunn Choi 96176476f3 Make fuzzy completion customizable with _fzf_compgen_{path,dir}
Notes:
- You can now override _fzf_compgen_path and _fzf_compgen_dir functions
  to use custom commands such as ag instead of find for listing
  completion candidates.
    - The first argument is the base path to start traversal
- Removed file-only completion in bash, i.e. _fzf_file_completion.
  Maintaining a list of commands that only expect files, not
  directories, is cumbersome (there are too many) and error-prone.

TBD:
- Added $FZF_COMPLETION_DIR_COMMANDS to customize the list of commands
  which use directory-only completion. The default is "cd pushd rmdir".
  Not sure if it's the best approach to address the requirement, I'll
  leave it as an undocumented feature.

Related: #406 (@thomcom), #456 (@frizinak)
9 years ago
Junegunn Choi 23244bb410 [fish] Fix intermittent errors on CTRL-T
This seems like a bug of fish, but sometimes when you select an item
fish complains:

"insertion mode switches can not be used when not in insertion mode"

This only happens when using tmux pane. Injecting a dummy command
somehow fixes the issue.
9 years ago
Kobe Lipkens 6208fc9cfd Fix autocompletion for absolute paths 9 years ago
Junegunn Choi e1dd798482 [bash/zsh-completion] List hidden files as well
Close #456 and #457
9 years ago
Kobe Lipkens 3b9984379c Pass FZF_DEFAULT_OPTS to non-interactive bash instance 9 years ago
Chaoren Lin 54b4b0c56f Dynamically select which __fzf_select__ to use for tmux with bash 4+.
Instead of choosing one at initialization, choose the correct one
when it's actually called, so that the behavior is correct even after
resizing.

Bonus fixes for tmux with bash 4+:
- No extra space when cancelling CTRL-T.
- Fix cursor position problem in vi mode.
9 years ago
Chaoren Lin 033afde3b5 Fix CTRL-T in tmux with non-standard configuration.
- Don't assume ~/.fzf.bash exists.
- Source the current script for __fzf_select__.
- Forward $PATH.
9 years ago
Daniel Hahler 701687faab zsh: fzf-completion: use noshwordsplit local option
This also fixes the completion causing a bell / flickering in case
"shwordsplit" was not set, because then the function would return false.
9 years ago
Daniel Hahler 95c69083c7 zsh completion: use \grep to skip any alias 9 years ago
Junegunn Choi 57a37b5832 [bash-completion] Fix #417 - Update command list 9 years ago
Junegunn Choi f1cd0e2daf [zsh] Fix #404 - Escape $ in $LBUFFER 9 years ago
Junegunn Choi e99731ea85 [shell] Add FZF_ALT_C_COMMAND for ALT-C (#408) 9 years ago
Leandro Freitas 3ef41845a9 [bash-completion] Add nvim to f_cmds 9 years ago
Jack Danger Canty c3cf3427b1 Not relying on exit status for CTRL-R
In the case that fzf-tmux returns a user-selected result but with a
non-zero exit status (which can happen if a function inside $PS1 returns
non-zero) this allows CTRL-R to continue working as expected.

Addresses #203 (Tranquility's comment)
9 years ago
Junegunn Choi 2c4f71d85b [zsh] fzf-history-widget - update local declaration 9 years ago
Junegunn Choi 81a88693c1 Make --extended default
Close #400
9 years ago
Junegunn Choi 486b87d821 [bash-completion] Retain original completion options (#288) 9 years ago
Junegunn Choi eee45a9578 [completion] Revamp completion API
* _fzf_complete is the helper function for custom completion
    * _fzf_complete FZF_OPTS ARGS
    * Reads the output of the source command instead of the command string
    * In zsh, you can use pipe to feed the data into the function, but
      it's not possible in bash as by doing so COMPREPLY is set from the
      subshell and thus nullified
* Change the naming convention for consistency:
    * _fzf_complete_COMMAND

e.g.

  # pass completion suggested by @d4ndo (#362)
  _fzf_complete_pass() {
    _fzf_complete '+m' "$@" < <(
      local pwdir=${PASSWORD_STORE_DIR-~/.password-store/}
      local stringsize="${#pwdir}"
      find "$pwdir" -name "*.gpg" -print |
          cut -c "$((stringsize + 1))"-  |
          sed -e 's/\(.*\)\.gpg/\1/'
    )
  }

  # Only in bash
  complete -F _fzf_complete_pass -o default -o bashdefault pass
9 years ago
Junegunn Choi 8fa9e85980 [zsh-completion] Allow custom completion function
While in bash you can externally register custom completion functions
using `complete` command, it was not possible to do so in zsh without
changing completion.zsh as the name of the supported commands are
hard-coded within the code (See #362). With this commit, fzf-completion
of zsh will first look if `_fzf_COMMAND_completion` exists and calls the
function, so one can externally define completion functions for specific
commands.

This commit also tries to make the interface of (yet undocumented)
_fzf_list_completion helper function consistent across bash and zsh.

So the following code works both on bash and zsh.

    _fzf_pass_completion() {
      local pwdir=${PASSWORD_STORE_DIR-~/.password-store/}
      local stringsize="${#pwdir}"
      let "stringsize+=1"
      _fzf_list_completion '+m' "$@" << "EOF"
        find "$pwdir" -name "*.gpg" -print | cut -c "$stringsize"- | sed -e 's/\(.*\)\.gpg/\1/'
    EOF
    }

    # Only on bash
    complete -F _fzf_pass_completion -o default -o bashdefault pass

Note that the suggested convention and the interface are not yet final
and subject to change.

/cc @d4ndo
9 years ago
Austin Ziegler ea271cd4e2 Remove dependency on zsh/pcre module
Fixes #363.
9 years ago
Junegunn Choi 2022a3ad96 Replace --header-file with --header (#346)
and allow using --header and --header-lines at the same time.

Close #346.
9 years ago
Junegunn Choi 5660cebaf6 [zsh-completion] Temporarily unset shwordsplit (#328) 9 years ago
Michał Kalbarczyk 5baf1c5536 fix fish streams 9 years ago
Junegunn Choi ee0c8a2635 Add --margin option
Close #299
9 years ago
Junegunn Choi 51d84b1869 [bash] Update fzf option completion 9 years ago
Junegunn Choi 392da53f53 [bash] Make CTRL-R work when histexpand is unset (#286)
Note that it still can't handle properly multi-line commands.
Thanks to @jpcirrus for the bug report and the fix.
9 years ago
Evgeny Vereshchagin a79d080ea8 Fix g++: possible retry loop
See http://unix.stackexchange.com/q/213432/120177
9 years ago
Junegunn Choi 938151a834 [shell] Add FZF_CTRL_T_COMMAND for CTRL-T
Close #40
9 years ago
Junegunn Choi 14e3b84073 [zsh] No need to define __fsel in non-interactive shell
Since we now use fzf-tmux instead of tmux split-window
9 years ago
Junegunn Choi 56100f0fa7 [bash] Use `command \find` for ALT-C
ALT-C can fail with the following aliases as pointed out in #272

    alias find='noglob find'
    alias command='command '
9 years ago
Junegunn Choi a336494f5d 0.10.0 9 years ago
Oliver Kiddle d395ebd28f use vi-fetch-history on zsh to get history line
In addition to being simpler, it allows subsequent up/down history
or accept-line-and-down-history widgets to work.
Also allow for find being and alias if alias expansion
after command is enabled.
9 years ago
Junegunn Choi 3b52811796 Add support for search history
- Add `--history` option (e.g. fzf --history ~/.fzf.history)
- Add `--history-max` option for limiting the size of the file (default 1000)
- Add `previous-history` and `next-history` actions for `--bind`
    - CTRL-P and CTRL-N are automatically remapped to these actions when
      `--history` is used

Closes #249, #251
9 years ago
Junegunn Choi 34946b72a5 0.9.12 9 years ago
Junegunn Choi 40761b11b1 [bash] Ignore asterisk (modified) in history 9 years ago
Junegunn Choi cca543d0cd [zsh-completion] Fix #236 - zle redisplay 9 years ago
Junegunn Choi b4a05ff27e [bash] CTRL-R to use history-expand-line
Close #146
9 years ago
Junegunn Choi 26d2af5ee8 [zsh-completion] Respect backslash-escaped spaces (#230) 9 years ago
Junegunn Choi 2b61dc6557 [zsh-completion] Do not overwrite $fzf_default_completion 9 years ago
Junegunn Choi 0b770cd48a [zsh-completion] Remember what ^I was originally bound to (#230) 9 years ago
Junegunn Choi c14aa99ef6 [zsh/bash-completion] Avoid caret expansion
Close #233

setopt extendedglob on zsh caused caret in grep pattern to be expanded.
Problem identified and patch submitted by @lazywei.
9 years ago
Junegunn Choi 8f371ee81c [zsh-completion] fzf-zsh-completion -> fzf-completion 9 years ago
Junegunn Choi 3b63b39810 [zsh-completion] Allow empty prefix & trigger sequence (#232) 9 years ago
Tiziano Santoro 0cd238700c [zsh-completion] Add comment clarifying trigger expansion. (#230) 9 years ago
Tiziano Santoro 14fbe06d9e [zsh-completion] Allow specifying empty completion trigger. (#230) 9 years ago
Junegunn Choi 64949bf467 [bash-completion] Allow specifying empty completion trigger (#230) 9 years ago
Robin Roth 01405ad92e fix typo in argument of head
at least my version of head wants -n1 to only display the first line
9 years ago
Junegunn Choi 207aa07891 [zsh-completion] Temporarily set nonomatch (#230)
No error on ~INVALID_USERNAME**<TAB>
9 years ago
Junegunn Choi 26a141c6a6 [zsh-completion] Fix `~USERNAME**` (#230) 9 years ago
Junegunn Choi dc64568c83 [zsh-completion] Completion for unknown commands 9 years ago
Junegunn Choi 5a17a6323a [zsh-completion] "\find" to bypass alias 9 years ago
Junegunn Choi 2b8e445321 Fuzzy completion for zsh (#227) 9 years ago
Junegunn Choi ed8202efc6 [bash-completion] Ignore 0.0.0.0
Close #228
9 years ago
Junegunn Choi c8f208b96b Merge pull request #171 from oschrenk/vi-insert-mode-key-bindings-fish
Support for vi insert mode in upcoming fish 2.2.0
10 years ago
Oliver Schrenk 2e339e49b8 Support for vi insert mode in upcoming fish 2.2.0 10 years ago
Junegunn Choi 22ae7adac8 Update completion for fzf itself 10 years ago
Junegunn Choi 36924d0b1c [zsh] Do not change LBUFFER on empty selection (CTRL-R) 10 years ago
Junegunn Choi 6ed9de9051 [zsh] Temporarily unset no_bang_hist for CTRL-R
Close #214
10 years ago
Junegunn Choi 305ec3b3ce [fish] Remove buffering delay by not using subroutines
Close #169
10 years ago
Junegunn Choi 06b4f75680 Fix broken FZF_TMUX switch and update test cases (#203) 10 years ago
Junegunn Choi 318edc8c35 Apply fzf-tmux to key bindings (#203)
Note that CTRL-T on bash is still using the old trick of send-keys.
10 years ago
Junegunn Choi d08542ce5d Prepare for 0.9.9 release 10 years ago
Junegunn Choi 3ec83babac FZF_TMUX and FZF_TMUX_HEIGHT for fuzzy completion 10 years ago
Junegunn Choi a4f3d09704 Fuzzy completion using fzf-tmux 10 years ago
Junegunn Choi 50292adacb Implement --toggle-sort option (#173) 10 years ago
Junegunn Choi c04e8de9b0 Make sure to start tmux pane from the current directory (#143)
- fzf-tmux
- CTRL-T of bash/zsh/fish
    - fish implementation may not work if the path contains
      double-quote characters (FIXME)
10 years ago
Junegunn Choi 3935aa84d8 Refactor shell extensions
- Use symlinks instead of generating the full content
- Update fish_user_paths and remove ~/.config/fish/functions/fzf.fish
- Create wrapper script for fzf when Ruby version and use it instead of
  exported function not to break fzf-tmux
10 years ago