1
0
Fork 0

bugfix lf function

This commit is contained in:
Luca Bilke 2024-03-20 12:17:15 +01:00
parent 2ab1f06269
commit 2e802a95a9
1 changed files with 14 additions and 13 deletions

View File

@ -132,36 +132,36 @@ cmd dupe &{{
# cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c
cmd fzf ${{
name="$1" input="$2" delimiter="$3" field="$4" width="$5" query="${6:-}"
histfile="$XDG_DATA_HOME/$(echo $name | tr '[:upper:]' '[:lower:]')_history"
name="$1" input="$2" delimiter="$3" field="$4" path_field="$5" width="$6" query="${7:-}"
histfile="$XDG_DATA_HOME/lf/$(echo $name | tr '[:upper:]' '[:lower:]')_history"
clear
file="$(eval "$input" | fzf \
--query "$query" \
--delimiter "$delimiter" \
--exact \
--select-1 \
--cycle \
--nth=1 \
--with-nth=1 \
--nth="$field" \
--with-nth="$field" \
--preview-window="right,$width" \
--bind="one:accept,focus:transform-preview-label(echo {} | cut -d '$delimiter' -f '$field')" \
--bind="one:accept,focus:transform-preview-label(echo {} | cut -d '$delimiter' -f '$path_field')" \
--scheme='history' \
--history="$histfile" \
--header="$name" \
--preview='
file=$(echo {} | cut -d '$delimiter' -f '$field')
file=$(echo {} | cut -d '$delimiter' -f '$path_field')
if [ -f "$file" ] && [ -r "$file" ]; then
head -$LINES "$file"
elif [ -d "$file" ] && [ -r "$file" ]; then
ls -pLHAN1 --color=always --group-directories-first "$file"
fi
' |
cut -d "$delimiter" -f "$field" |
cut -d "$delimiter" -f "$path_field" |
tr -d '\n'
)"
[ -d "$file" ] && lf -remote "send $id cd $file" && return 0
[ -d "$file" ] && lf -remote "send $id cd $file"
[ -f "$file" ] && lf -remote "send $id select $file"
return 0
}}
cmd find_word ${{
@ -190,6 +190,7 @@ cmd find_word ${{
lf -remote "send $id \$$EDITOR '$file'"
fi
fi
return 0
}}
cmd extract ${{
@ -243,10 +244,10 @@ map <esc> quit
map <space> :toggle; down
map <enter> shell
map <a-enter> shell-wait
map <tab> fzf 'Shortcuts' 'cat $XDG_DATA_HOME/lf/shortcuts 2>/dev/null' ':' '2' '85%' '^'
map -t fzf 'Tags' 'cat $XDG_DATA_HOME/lf/tags 2>/dev/null' ':' '1' '50%' '^'
map -m fzf 'Marks' 'cat $XDG_DATA_HOME/lf/marks 2>/dev/null' ':' '2' '85%' '^'
map -f fzf 'Files' 'find -L $PWD' ':' '1' '50%'
map <tab> fzf 'Shortcuts' 'cat $XDG_DATA_HOME/lf/shortcuts 2>/dev/null' ':' '1' '2' '85%' '^'
map -t fzf 'Tags' 'cat $XDG_DATA_HOME/lf/tags 2>/dev/null' ':' '1' '1' '50%'
map -m fzf 'Marks' 'cat $XDG_DATA_HOME/lf/marks 2>/dev/null' ':' '1' '2' '85%' '^'
map -f fzf 'Files' 'find -L $PWD' ':' '1' '1' '50%'
map -g find_word
map "'" mark-load
map '"' mark-remove