fdfind functions now follow symlinks

This commit is contained in:
gardouille 2023-11-02 11:39:22 +01:00
parent 9295fa6dfa
commit 0efcde9399
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 26 additions and 26 deletions

52
zshrc
View File

@ -2091,10 +2091,10 @@ function ff() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
dir=$(find . -xtype d -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi) &&
dir=$(find . -xtype d --follow -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
dir=$(find . -xtype d -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
dir=$(find . -xtype d --follow -not -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
fi
## }}}
@ -2113,10 +2113,10 @@ function ffh() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
dir=$(find . -xtype d -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi) &&
dir=$(find . -xtype d --follow -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
dir=$(find . -xtype d -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
dir=$(find . -xtype d --follow -path "*/.*" | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 {} | head --lines=20' --no-multi --query "${*} ") &&
fi
## }}}
@ -2135,10 +2135,10 @@ function ffa() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
dir=$(fd -uu --search-path / --type d --type symlink | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 {} | head --lines=20' --no-multi) &&
dir=$(fd -uu --search-path / --type d --type symlink --follow | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 {} | head --lines=20' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
dir=$(fd -uu --search-path / --type d --type symlink | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 {} | head --lines=20' --no-multi --query "${*} ") &&
dir=$(fd -uu --search-path / --type d --type symlink --follow | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 {} | head --lines=20' --no-multi --query "${*} ") &&
fi
## }}}
@ -2186,10 +2186,10 @@ function fff() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
file=$(fd -uu --type file --type symlink | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 $(dirname {}) | head --lines=20' --no-multi) &&
file=$(fd -uu --type file --type symlink --follow | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 $(dirname {}) | head --lines=20' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
file=$(fd -uu --type file --type symlink | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
file=$(fd -uu --type file --type symlink --follow | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 2 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
fi
## }}}
@ -2208,10 +2208,10 @@ function cf() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
file=$(fd -uu --search-path / | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 $(dirname {}) | head --lines=20' --no-multi) &&
file=$(fd -uu --search-path / --follow | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 $(dirname {}) | head --lines=20' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
file=$(fd -uu --search-path / | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
file=$(fd -uu --search-path / --follow | fzf --prompt='cd> ' --height=50% --preview 'eza --tree --level 1 $(dirname {}) | head --lines=20' --no-multi --query "${*} ") &&
fi
## }}}
@ -2244,10 +2244,10 @@ function v() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
files=$(fd -uu --type file --type symlink | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi) &&
files=$(fd -uu --type file --type symlink --follow | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd -uu --type file --type symlink | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi --query "${*} ") &&
files=$(fd -uu --type file --type symlink --follow | fzf --prompt='vi> ' --preview 'bat --color=always --line-range 0:50 {}' --no-multi --query "${*} ") &&
fi
## }}}
@ -2278,10 +2278,10 @@ function pdf() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
files=$(fd --unrestricted --type file --type symlink --follow "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
files=$(fd --unrestricted --type file --type symlink --follow "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
fi
## }}}
@ -2319,10 +2319,10 @@ function pdfe() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
files=$(fd --unrestricted --type file --type symlink --follow "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
files=$(fd --unrestricted --type file --type symlink --follow "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
fi
## }}}
@ -2359,10 +2359,10 @@ function pdfz() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
files=$(fd --unrestricted --type file --type symlink --follow "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd --unrestricted --type file --type symlink "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
files=$(fd --unrestricted --type file --type symlink --follow "\.pdf$" | fzf --prompt='pdf> ' --preview 'lesspipe {} | less' --no-multi --query "${*} ") &&
fi
## }}}
@ -2390,10 +2390,10 @@ function odt() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi) &&
files=$(fd --unrestricted --type file --type symlink --follow "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd --unrestricted --type file --type symlink "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi --query "${*} ") &&
files=$(fd --unrestricted --type file --type symlink --follow "\.(odt|rtf|doc|docx)" | fzf --prompt='odt> ' --no-multi --query "${*} ") &&
fi
## }}}
@ -2421,10 +2421,10 @@ function ods() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi) &&
files=$(fd --unrestricted --type file --type symlink --follow "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd --unrestricted --type file --type symlink "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi --query "${*} ") &&
files=$(fd --unrestricted --type file --type symlink --follow "\.(ods|xls|xlsx)" | fzf --prompt='ods> ' --no-multi --query "${*} ") &&
fi
## }}}
@ -2452,10 +2452,10 @@ function odp() {
## Manage argument {{{
if [ "${#}" -eq "0" ]; then
## Default command without args
files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi) &&
files=$(fd --unrestricted --type file --type symlink --follow "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd --unrestricted --type file --type symlink "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi "${*} ") &&
files=$(fd --unrestricted --type file --type symlink --follow "\.(odp|ppt|pptx)" | fzf --prompt='odp> ' --no-multi "${*} ") &&
fi
## }}}
@ -2484,10 +2484,10 @@ function fopen() {
## Manage argument {{{
if [ "${#}" -le "1" ]; then
## Default command with one argument or default value
files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --prompt='open> ' --no-multi) &&
files=$(fd --unrestricted --type file --type symlink --follow "${1:-.}" | fzf --prompt='open> ' --no-multi) &&
else
## If at least one argument was given, add it to fzf query
files=$(fd --unrestricted --type file --type symlink "${1:-.}" | fzf --prompt='open> ' --no-multi --query "${*} ") &&
files=$(fd --unrestricted --type file --type symlink --follow "${1:-.}" | fzf --prompt='open> ' --no-multi --query "${*} ") &&
fi
## }}}