Commit Graph

124 Commits (master)

Author SHA1 Message Date
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)
8 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
Junegunn Choi 57a37b5832 [bash-completion] Fix #417 - Update command list 9 years ago
Leandro Freitas 3ef41845a9 [bash-completion] Add nvim to f_cmds 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
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 ee0c8a2635 Add --margin option
Close #299
9 years ago
Junegunn Choi 51d84b1869 [bash] Update fzf option completion 9 years ago
Evgeny Vereshchagin a79d080ea8 Fix g++: possible retry loop
See http://unix.stackexchange.com/q/213432/120177
9 years ago
Junegunn Choi a336494f5d 0.10.0 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 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 64949bf467 [bash-completion] Allow specifying empty completion trigger (#230) 9 years ago
Junegunn Choi ed8202efc6 [bash-completion] Ignore 0.0.0.0
Close #228
9 years ago
Junegunn Choi 22ae7adac8 Update completion for fzf itself 9 years ago
Junegunn Choi d08542ce5d Prepare for 0.9.9 release 9 years ago
Junegunn Choi 3ec83babac FZF_TMUX and FZF_TMUX_HEIGHT for fuzzy completion 9 years ago
Junegunn Choi a4f3d09704 Fuzzy completion using fzf-tmux 9 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
9 years ago