diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 5ae344a8..6cb8f60c 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -10,25 +10,54 @@ set period 1 set previewer "~/.config/lf/preview/chafa" set cursorpreviewfmt "\033[7;90m" set promptfmt "\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m%d\033[35m]\033[32m ยป \033[33m%f\033[0m" +set opener=opener -cmd open $set -f; rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -p 0 $fx; clear +cmd pushedit %{{ + echo "Open: " + files=$(read x; echo $x) + if sh -c '[ -n "$VIM" ]'; then + lf -remote "send $id vimopen $files" + else + lf -remote "send $id \$echo $files | xargs -or nvim +wa" + fi + lf -remote "send $id reload" +}} + +cmd edit ${{ + rifle -c "$XDG_CONFIG_HOME/lf/rifle.conf" -p 0 $fx + # if sh -c "[ -n '\$VIM' ]"; then + # lf -remote "send $id vimopen $fx" + # else + # lf -remote "send $id '\$echo $fx | xargs -or nvim +wa'" + # fi +}} cmd open-with ${{ - method=$(rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -l $fx | fzf | cut -d':' -f1) + method=$(rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -l $fx | fzf --header="Choose an application:" | cut -d':' -f1) rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -p $method $fx }} +cmd vimopen &{{ + touch "$@" + lf -remote "$( + for f in "$@"; do printf "%b" "send $id toggle $f\n"; done + printf "%b" "send $id select $f\n" + printf "%b" "send $id open\n" + printf "%b" "send $id unselect\n" + )" +}} + cmd mkdir &mkdir -p "$(echo $* | tr ' ' '\ ')" cmd trash &{{ for f in $fx; do trash-put $f & done - lf -remote "send $id load" + lf -remote "send load" }} -cmd lazygit ${{ - cd "$(dirname "$(realpath "$f")")" && lazygit +cmd lazygit &{{ + lf -remote "send $id \$cd "$(dirname "$(realpath "$f")")" && lazygit" }} # y (select for copy) and P to paste soft-link @@ -96,22 +125,22 @@ cmd dupe &{{ # cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c cmd fzfsearch ${{ - file="$(find $PWD | fzf)" + file="$(find -L $PWD | fzf --header="Searching Filenames")" [ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -f $file ] && lf -remote "send $id select $file" }} cmd fzftags ${{ - file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/tags | sed 's/:\*$//' | fzf)" + file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/tags | sed 's/:\*$//' | fzf --header="Searching Tags")" [ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -f $file ] && lf -remote "send $id select $file" }} cmd fzfmarks ${{ - file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/marks | sed 's/^.://' | fzf)" + file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/marks | sed 's/^.://' | fzf --header="Searching Marks")" [ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -f $file ] && lf -remote "send $id select $file" }} cmd fzfshortcut ${{ - file="$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc | cut -d '"' -f2 | fzf)" + file="$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc | cut -d '"' -f2 | fzf --header="Searching Shortcuts")" [ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -f $file ] && lf -remote "send $id select $file" }} @@ -120,15 +149,17 @@ cmd fzfgrep ${{ res="$( FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \ fzf --bind "change:reload:$RG_PREFIX {q} || true" \ - --ansi --layout=reverse --header 'Search in files' |\ + --ansi --layout=reverse --header 'Searching file contents' |\ grep -iv -e 'Trash/files' -e 'Trash/info' )" file="$(echo $res | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')" row="$(echo $res | cut -d':' -f2)" column="$(echo $res | cut -d':' -f3)" if [ -n "$res" ]; then - lf -remote "send ${id} select '$file'" - if [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then + lf -remote "send $id select '$file'" + if [ -n "$VIM" ]; then + lf -remote "send $id open '$file'" + elsif [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then lf -remote "send $id \$$EDITOR '$file' +'call cursor($row, $column)'" else lf -remote "send $id \$$EDITOR '$file'" @@ -185,7 +216,7 @@ map extract map P link # map S share map lazygit -map push :!$EDITOR +map pushedit map push :mkdir map N push :&touch map reload @@ -205,7 +236,7 @@ map n &echo $f | xclip -r -selection c map quit map g/ cd "/" map W new_lf_term -map e $$EDITOR $f +map e edit map E $sudo -e $f # Load bookmark shortcuts diff --git a/.config/lf/opener b/.config/lf/opener new file mode 100755 index 00000000..2f1e723a --- /dev/null +++ b/.config/lf/opener @@ -0,0 +1,11 @@ +#!/bin/sh +set -f + +if [ "$2" ]; then + for f in "$@"; do + # shellcheck disable=2086 + rifle -p0 $f + done +else + rifle -c "$XDG_CONFIG_HOME/lf/rifle.conf" -p 0 "$1" +fi diff --git a/.config/lf/todo b/.config/lf/todo index 19fb367a..de835e27 100644 --- a/.config/lf/todo +++ b/.config/lf/todo @@ -1 +1,6 @@ gpg asks for unlock when viewing gpg keys +rework rifle.conf +look into perl-File-MimeInfo +look into mimeo +Get the swallow patch up and running asap! +inode/directory handler for forking/terminal