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

View file

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