From b4ecb71d0ba2725b05fbdd977acc301c2430970f Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Thu, 15 Jun 2023 17:27:56 +0200 Subject: [PATCH] small improvements --- .config/lf/lfrc | 29 ++++++++++++++--------------- .config/lf/preview | 2 +- .config/zsh/.zprofile | 1 + .config/zsh/completions/_lf | 22 ++++++++++++++++++++++ .config/zsh/configs/aliases | 2 +- 5 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 .config/zsh/completions/_lf diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 925c8d069..514b56734 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -9,6 +9,7 @@ set wrapscroll set period 1 set previewer ~/.config/lf/preview set cleaner ~/.config/lf/clean +set drawbox # promptfmt is set in the on-cd command cmd open $set -f; rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -p 0 $fx; clear @@ -111,13 +112,7 @@ cmd paste &{{ mode="$1" shift case "$mode" in - copy) - rsync -av --ignore-existing --progress -- "$@" . | - stdbuf -i0 -o0 -e0 tr '\r' '\n' | - while IFS= read -r line; do - lf -remote "send $id echo $line" - done - ;; + copy) cp -rn -- "$@" .;; move) mv -n -- "$@" .;; esac rm ~/.local/share/lf/files @@ -170,6 +165,16 @@ cmd fzfshortcutdirs ${{ [ -d $file ] && lf -remote "send $id cd $file" lf -remote "send $id select $file" }} +cmd fzfgrep ${{ + RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case " + res="$( + FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \ + fzf --bind "change:reload:$RG_PREFIX {q} || true" \ + --ansi --layout=reverse --header 'Search in files' \ + | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g' + )" + [ -n "$res" ] && lf -remote "send $id select \"$res\"" +}} # Bindings map a fzfsearch @@ -177,6 +182,7 @@ map t fzftags map m fzfmarks map f fzfshortcutfiles map d fzfshortcutdirs +map g fzfgrep map J $dir=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf) && lf -remote "send $id cd $(eval echo $dir)" map D trash map delete @@ -195,9 +201,7 @@ map shell map x $$f map X !$f map o open-with -map A rename # at the very end map a push A # at the very beginning -map I push A # after extension map i push A # before extension map c push A # new rename map B bulkrename @@ -205,14 +209,9 @@ map b dupe map u :clear; unselect map n &echo $f | xclip -r -selection c map quit -map N map g/ cd "/" -map W &setsid $TERMINAL -e $SHELL -c "lf; $SHELL" +map W &setsid $TERMINAL -e lf map e edit - -# Kitty Specific -map W &setsid $TERMINAL $SHELL -c "lf; exec $SHELL" - # Load bookmark shortcuts source "~/.config/lf/shortcutrc" diff --git a/.config/lf/preview b/.config/lf/preview index c088900d2..35aefbbda 100755 --- a/.config/lf/preview +++ b/.config/lf/preview @@ -11,7 +11,7 @@ image() { y=$5 # kitty +kitten icat --clear --stdin no --silent --transfer-mode memory --place "${w}x${h}@${x}x${y}" "$f" >/dev/tty if [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; then - printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG" + printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$(($4 + 3))" "$(($5 + 1))" "$(($2-6))" "$(($3-2))" "$1" > "$FIFO_UEBERZUG" fi exit 1 } diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index 66bb269eb..11cd05e5e 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -93,6 +93,7 @@ export W3M_DIR="$XDG_DATA_HOMEA/w3m" export RUSTUP_HOME="$XDG_DATA_HOME/rustup" localpath="$(find -L ~/.local/bin -type d -printf %p: | sed 's/.$//')" +fpath=($XDG_CONFIG_HOME/zsh/completions $fpath) export PATH="$PATH:$HOME/.local/share/npm-global/bin:$localpath" export NVM_DIR="$HOME/.config/nvm" diff --git a/.config/zsh/completions/_lf b/.config/zsh/completions/_lf new file mode 100644 index 000000000..25e908c3c --- /dev/null +++ b/.config/zsh/completions/_lf @@ -0,0 +1,22 @@ +#compdef lf + +local arguments + +arguments=( + '-command[command to execute on client initialization]' + '-config[path to the config file (instead of the usual paths)]' + '-cpuprofile[path to the file to write the CPU profile]' + '-doc[show documentation]' + '-last-dir-path[path to the file to write the last dir on exit (to use for cd)]' + '-log[path to the log file to write messages]' + '-memprofile[path to the file to write the memory profile]' + '-remote[send remote command to server]' + '-selection-path[path to the file to write selected files on open (to use as open file dialog)]' + '-server[start server (automatic)]' + '-single[start a client without server]' + '-version[show version]' + '-help[show help]' + '*:filename:_files' +) + +_arguments -s $arguments diff --git a/.config/zsh/configs/aliases b/.config/zsh/configs/aliases index d23ec2f0d..bfb5a58e5 100644 --- a/.config/zsh/configs/aliases +++ b/.config/zsh/configs/aliases @@ -57,7 +57,7 @@ fi # Misc. alias \ - ll="ls -alhN --color=auto --group-directories-first" \ + ll="ls -lhpAN --color=auto --group-directories-first" \ subpush="git push --recurse-submodules=on-demand" \ ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \ weath="less -S ${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" \