FZF: Add default options and prompt
This commit is contained in:
parent
87ce125e42
commit
5c6b4d46a9
59
zshrc
59
zshrc
|
@ -1806,6 +1806,8 @@ if [ -f ~/bin/fd ]; then
|
||||||
export FZF_DEFAULT_COMMAND='fd --type f'
|
export FZF_DEFAULT_COMMAND='fd --type f'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export FZF_DEFAULT_OPTS="--cycle --multi --select-1 --bind change:first"
|
||||||
|
|
||||||
# Auto-completion
|
# Auto-completion
|
||||||
# ---------------
|
# ---------------
|
||||||
[[ $- == *i* ]] && source "${HOME}/.fzf/shell/completion.zsh" 2> /dev/null
|
[[ $- == *i* ]] && source "${HOME}/.fzf/shell/completion.zsh" 2> /dev/null
|
||||||
|
@ -1826,10 +1828,10 @@ ff() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
dir=$(find . -xtype d -not -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) &&
|
dir=$(find . -xtype d -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
dir=$(find . -xtype d -not -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
|
dir=$(find . -xtype d -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -1848,10 +1850,10 @@ ffh() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
dir=$(find . -xtype d -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) &&
|
dir=$(find . -xtype d -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
dir=$(find . -xtype d -path "*/.*" | fzf --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
|
dir=$(find . -xtype d -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -1870,10 +1872,10 @@ ffa() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
dir=$(fd -uu --search-path / --type d --type symlink | fzf --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi) &&
|
dir=$(fd -uu --search-path / --type d --type symlink | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
dir=$(fd -uu --search-path / --type d --type symlink | fzf --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi --query "${*} ") &&
|
dir=$(fd -uu --search-path / --type d --type symlink | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 {} | head --lines=20' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -1898,10 +1900,10 @@ ffu() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --tac --height=50% --no-multi) &&
|
dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --prompt='cd> ' --tac --height=50% --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --tac --height=50% --no-multi --query "${*} ") &&
|
dir=$(get_parent_dirs $(realpath "${PWD}") | fzf --prompt='cd> ' --tac --height=50% --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -1921,10 +1923,10 @@ fff() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
file=$(find . -xtype f | fzf --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi) &&
|
file=$(find . -xtype f | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
file=$(find . -xtype f | fzf --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
|
file=$(find . -xtype f | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 2 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -1943,11 +1945,10 @@ cf() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
#file="$(locate -Ai -0 $@ | grep -z -vE '~$' | fzf --read0 -0 -1)"
|
file=$(fd -uu --search-path / | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi) &&
|
||||||
file=$(fd -uu --search-path / | fzf --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi) &&
|
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
file=$(fd -uu --search-path / | fzf --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
|
file=$(fd -uu --search-path / | fzf --prompt='cd> ' --height=50% --preview 'exa --tree --level 1 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -1980,10 +1981,10 @@ v() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
files=$(fd -uu --type file --type symlink | fzf --preview 'bat --color=always --line-range 0:50 {}' --no-multi) &&
|
files=$(fd -uu --type file --type symlink | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd -uu --type file --type symlink | fzf --preview 'bat --color=always --line-range 0:50 {}' --no-multi --query "${*} ") &&
|
files=$(fd -uu --type file --type symlink | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -2015,10 +2016,10 @@ pdf() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi) &&
|
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
|
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -2055,10 +2056,10 @@ pdfe() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi) &&
|
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
|
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -2095,10 +2096,10 @@ pdfz() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi) &&
|
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
|
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -2126,10 +2127,10 @@ odt() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --no-multi) &&
|
files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --no-multi --query "${*} ") &&
|
files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -2156,10 +2157,10 @@ ods() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --no-multi) &&
|
files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --no-multi --query "${*} ") &&
|
files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -2186,10 +2187,10 @@ odp() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -eq "0" ]; then
|
if [ "${#}" -eq "0" ]; then
|
||||||
## Default command without args
|
## Default command without args
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --no-multi) &&
|
files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --no-multi "${*} ") &&
|
files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -2217,10 +2218,10 @@ fopen() {
|
||||||
## Manage argument {{{
|
## Manage argument {{{
|
||||||
if [ "${#}" -le "1" ]; then
|
if [ "${#}" -le "1" ]; then
|
||||||
## Default command with one argument or default value
|
## Default command with one argument or default value
|
||||||
files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --no-multi) &&
|
files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --prompt='open> ' --no-multi) &&
|
||||||
else
|
else
|
||||||
## If at least one argument was given, add it to fzf query
|
## If at least one argument was given, add it to fzf query
|
||||||
files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --no-multi --query "${*} ") &&
|
files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --prompt='open> ' --no-multi --query "${*} ") &&
|
||||||
fi
|
fi
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue