knox revidoval tento gist . Přejít na revizi
1 file changed, 32 insertions
fzf-23.sh(vytvořil soubor)
@@ -0,0 +1,32 @@ | |||
1 | + | # Use ~~ as the trigger sequence instead of the default ** | |
2 | + | export FZF_COMPLETION_TRIGGER='~~' | |
3 | + | ||
4 | + | # Options to fzf command | |
5 | + | export FZF_COMPLETION_OPTS='--border --info=inline' | |
6 | + | ||
7 | + | # Use fd (https://github.com/sharkdp/fd) for listing path candidates. | |
8 | + | # - The first argument to the function ($1) is the base path to start traversal | |
9 | + | # - See the source code (completion.{bash,zsh}) for the details. | |
10 | + | _fzf_compgen_path() { | |
11 | + | fd --hidden --follow --exclude ".git" . "$1" | |
12 | + | } | |
13 | + | ||
14 | + | # Use fd to generate the list for directory completion | |
15 | + | _fzf_compgen_dir() { | |
16 | + | fd --type d --hidden --follow --exclude ".git" . "$1" | |
17 | + | } | |
18 | + | ||
19 | + | # Advanced customization of fzf options via _fzf_comprun function | |
20 | + | # - The first argument to the function is the name of the command. | |
21 | + | # - You should make sure to pass the rest of the arguments to fzf. | |
22 | + | _fzf_comprun() { | |
23 | + | local command=$1 | |
24 | + | shift | |
25 | + | ||
26 | + | case "$command" in | |
27 | + | cd) fzf --preview 'tree -C {} | head -200' "$@" ;; | |
28 | + | export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;; | |
29 | + | ssh) fzf --preview 'dig {}' "$@" ;; | |
30 | + | *) fzf --preview 'bat -n --color=always {}' "$@" ;; | |
31 | + | esac | |
32 | + | } |
Novější
Starší