Switch from ranger to lf

This commit is contained in:
pancakes 2024-04-02 18:19:35 +10:00
parent 194a59608e
commit 14dfabcf4e
7 changed files with 612 additions and 4 deletions

View file

@ -38,7 +38,7 @@ Menu: [Fuzzel](https://codeberg.org/dnkl/fuzzel) - [config](fuzzel/.config/fuzze
Wallpaper Daemon: [swww](https://github.com/Horus645/swww)
File Manager: [ranger](https://github.com/ranger/ranger) - [config](ranger/.config/ranger/rc.conf) / Thunar
File Manager: [lf](https://github.com/gokcehan/lf) - [config](lf/.config/lf/lfrc) / Thunar
Image/Video Player: [imv](https://sr.ht/~exec64/imv/) / [mpv](https://mpv.io/) - [config]

View file

@ -71,14 +71,14 @@ setup-waydroid:
stow:
stow btop
stow code
stow gtk
stow fuzzel
stow gtk
stow kanshi
stow kitty
stow lf
stow mako
stow mangohud
stow mpv
stow ranger
stow river
stow swaylock
stow waybar

361
lf/.config/lf/icons Normal file
View file

@ -0,0 +1,361 @@
# vim:ft=conf
# These examples require Nerd Fonts or a compatible font to be used.
# See https://www.nerdfonts.com for more information.
# default values from lf (with matching order)
# ln l # LINK
# or l # ORPHAN
# tw t # STICKY_OTHER_WRITABLE
# ow d # OTHER_WRITABLE
# st t # STICKY
# di d # DIR
# pi p # FIFO
# so s # SOCK
# bd b # BLK
# cd c # CHR
# su u # SETUID
# sg g # SETGID
# ex x # EXEC
# fi - # FILE
# file types (with matching order)
ln  # LINK
or  # ORPHAN
tw t # STICKY_OTHER_WRITABLE
ow  # OTHER_WRITABLE
st t # STICKY
di  # DIR
pi p # FIFO
so s # SOCK
bd b # BLK
cd c # CHR
su u # SETUID
sg g # SETGID
ex  # EXEC
fi  # FILE
# file extensions (vim-devicons)
*.styl 
*.sass 
*.scss 
*.htm 
*.html 
*.slim 
*.haml 
*.ejs 
*.css 
*.less 
*.md 
*.mdx 
*.markdown 
*.rmd 
*.json 
*.webmanifest 
*.js 
*.mjs 
*.jsx 
*.rb 
*.gemspec 
*.rake 
*.php 
*.py 
*.pyc 
*.pyo 
*.pyd 
*.coffee 
*.mustache 
*.hbs 
*.conf 
*.ini 
*.yml 
*.yaml 
*.toml 
*.bat 
*.mk 
*.jpg 
*.jpeg 
*.bmp 
*.png 
*.webp 
*.gif 
*.ico 
*.twig 
*.cpp 
*.c++ 
*.cxx 
*.cc 
*.cp 
*.c 
*.cs 󰌛
*.h 
*.hh 
*.hpp 
*.hxx 
*.hs 
*.lhs 
*.nix 
*.lua 
*.java 
*.sh 
*.fish 
*.bash 
*.zsh 
*.ksh 
*.csh 
*.awk 
*.ps1 
*.ml λ
*.mli λ
*.diff 
*.db 
*.sql 
*.dump 
*.clj 
*.cljc 
*.cljs 
*.edn 
*.scala 
*.go 
*.dart 
*.xul 
*.sln 
*.suo 
*.pl 
*.pm 
*.t 
*.rss 
'*.f#' 
*.fsscript 
*.fsx 
*.fs 
*.fsi 
*.rs 
*.rlib 
*.d 
*.erl 
*.hrl 
*.ex 
*.exs 
*.eex 
*.leex 
*.heex 
*.vim 
*.ai 
*.psd 
*.psb 
*.ts 
*.tsx 
*.jl 
*.pp 
*.vue 
*.elm 
*.swift 
*.xcplayground 
*.tex 󰙩
*.r 󰟔
*.rproj 󰗆
*.sol 󰡪
*.pem 
# file names (vim-devicons) (case-insensitive not supported in lf)
*gruntfile.coffee 
*gruntfile.js 
*gruntfile.ls 
*gulpfile.coffee 
*gulpfile.js 
*gulpfile.ls 
*mix.lock 
*dropbox 
*.ds_store 
*.gitconfig 
*.gitignore 
*.gitattributes 
*.gitlab-ci.yml 
*.bashrc 
*.zshrc 
*.zshenv 
*.zprofile 
*.vimrc 
*.gvimrc 
*_vimrc 
*_gvimrc 
*.bashprofile 
*favicon.ico 
*license 
*node_modules 
*react.jsx 
*procfile 
*dockerfile 
*docker-compose.yml 
*docker-compose.yaml 
*compose.yml 
*compose.yaml 
*rakefile 
*config.ru 
*gemfile 
*makefile 
*cmakelists.txt 
*robots.txt 󰚩
# file names (case-sensitive adaptations)
*Gruntfile.coffee 
*Gruntfile.js 
*Gruntfile.ls 
*Gulpfile.coffee 
*Gulpfile.js 
*Gulpfile.ls 
*Dropbox 
*.DS_Store 
*LICENSE 
*React.jsx 
*Procfile 
*Dockerfile 
*Docker-compose.yml 
*Docker-compose.yaml 
*Rakefile 
*Gemfile 
*Makefile 
*CMakeLists.txt 
# file patterns (vim-devicons) (patterns not supported in lf)
# .*jquery.*\.js$ 
# .*angular.*\.js$ 
# .*backbone.*\.js$ 
# .*require.*\.js$ 
# .*materialize.*\.js$ 
# .*materialize.*\.css$ 
# .*mootools.*\.js$ 
# .*vimrc.* 
# Vagrantfile$ 
# file patterns (file name adaptations)
*jquery.min.js 
*angular.min.js 
*backbone.min.js 
*require.min.js 
*materialize.min.js 
*materialize.min.css 
*mootools.min.js 
*vimrc 
Vagrantfile 
# archives or compressed (extensions from dircolors defaults)
*.tar 
*.tgz 
*.arc 
*.arj 
*.taz 
*.lha 
*.lz4 
*.lzh 
*.lzma 
*.tlz 
*.txz 
*.tzo 
*.t7z 
*.zip 
*.z 
*.dz 
*.gz 
*.lrz 
*.lz 
*.lzo 
*.xz 
*.zst 
*.tzst 
*.bz2 
*.bz 
*.tbz 
*.tbz2 
*.tz 
*.deb 
*.rpm 
*.jar 
*.war 
*.ear 
*.sar 
*.rar 
*.alz 
*.ace 
*.zoo 
*.cpio 
*.7z 
*.rz 
*.cab 
*.wim 
*.swm 
*.dwm 
*.esd 
# image formats (extensions from dircolors defaults)
*.jpg 
*.jpeg 
*.mjpg 
*.mjpeg 
*.gif 
*.bmp 
*.pbm 
*.pgm 
*.ppm 
*.tga 
*.xbm 
*.xpm 
*.tif 
*.tiff 
*.png 
*.svg 
*.svgz 
*.mng 
*.pcx 
*.mov 
*.mpg 
*.mpeg 
*.m2v 
*.mkv 
*.webm 
*.ogm 
*.mp4 
*.m4v 
*.mp4v 
*.vob 
*.qt 
*.nuv 
*.wmv 
*.asf 
*.rm 
*.rmvb 
*.flc 
*.avi 
*.fli 
*.flv 
*.gl 
*.dl 
*.xcf 
*.xwd 
*.yuv 
*.cgm 
*.emf 
*.ogv 
*.ogx 
# audio formats (extensions from dircolors defaults)
*.aac 
*.au 
*.flac 
*.m4a 
*.mid 
*.midi 
*.mka 
*.mp3 
*.mpc 
*.ogg 
*.ra 
*.wav 
*.oga 
*.opus 
*.spx 
*.xspf 
# other formats
*.pdf 

222
lf/.config/lf/lfrc Normal file
View file

@ -0,0 +1,222 @@
# interpreter for shell commands
set shell sh
# set '-eu' options for shell commands
# These options are used to have safer shell commands. Option '-e' is used to
# exit on error and option '-u' is used to give error for unset variables.
# Option '-f' disables pathname expansion which can be useful when $f, $fs, and
# $fx variables contain names with '*' or '?' characters. However, this option
# is used selectively within individual commands as it can be limiting at
# times.
set shellopts '-eu'
# set internal field separator (IFS) to "\n" for shell commands
# This is useful to automatically split file names in $fs and $fx properly
# since default file separator used in these variables (i.e. 'filesep' option)
# is newline. You need to consider the values of these options and create your
# commands accordingly.
set ifs "\n"
# leave some space at the top and the bottom of the screen
set scrolloff 10
# Use the `dim` attribute instead of underline for the cursor in the preview pane
set cursorpreviewfmt "\033[7;2m"
# Image previews
set cleaner ~/.config/lf/scripts/lf_kitty_clean
set previewer ~/.config/lf/scripts/lf_kitty_preview
# enable icons
set icons
# automatic refresh
set period 1
# file and dir size
set info size
set dircounts
# remap goto top and bottom
map J bottom
map gg
map K top
# cool dirs and shit
map gc cd ~/Projects
map gC cd ~/config
map gd cd ~/Documents
map gD cd ~/Downloads
# games
map gge cd ~/Emulation
map ggm cd ~/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher/instances
map ggs cd ~/.local/share/Steam/steamapps/common
# music
map gm cd ~/Music
# pictures
map gps cd ~/Pictures/Screenshots
map gpp cd ~/Pictures
map gpw cd ~/Pictures/Wallpapers
# videos
map gvr cd ~/Videos/Recording
map gvv cd ~/Videos
# use enter for shell commands
map <enter> shell
# show the result of execution of previous commands
map ` !true
# execute current file (must be executable)
map x $$f
map X !$f
# dedicated keys for file opener actions
map o &mimeopen $f
map O $mimeopen --ask $f
# define a custom 'open' command
# This command is called when current file is not a directory. You may want to
# use either file extensions and/or mime types here. Below uses an editor for
# text files and a file opener for the rest.
cmd open &{{
case $(file --mime-type -Lb $f) in
text/*) lf -remote "send $id \$$EDITOR \$fx";;
*) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;;
esac
}}
# mkdir command. See wiki if you want it to select created dir
map a :push %mkdir<space>
# define a custom 'rename' command without prompt for overwrite
# cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
# map r push :rename<space>
# make sure trash folder exists
# %mkdir -p ~/.trash
# move current file or selected files to trash folder
cmd trash %trash-put $fx
# use '<delete>' key for either 'trash' or 'delete' command
map <delete> trash
map D trash
# map <delete> delete
# extract the current file with the right command
# (xkcd link: https://xkcd.com/1168/)
cmd extract ${{
set -f
case $f in
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
*.tar.gz|*.tgz) tar xzvf $f;;
*.tar.xz|*.txz) tar xJvf $f;;
*.zip) unzip $f;;
*.rar) unrar x $f;;
*.7z) 7z x $f;;
esac
}}
# compress current file or selected files with tar and gunzip
cmd tar ${{
set -f
mkdir $1
cp -r $fx $1
tar czf $1.tar.gz $1
rm -rf $1
}}
# compress current file or selected files with zip
cmd zip ${{
set -f
mkdir $1
cp -r $fx $1
zip -r $1.zip $1
rm -rf $1
}}
# use eza instead of ls for file info
cmd on-select &{{
lf -remote "send $id set statfmt \"$(eza -ld --color=always "$f")\""
}}
cmd on-cd &{{
# display repository status in your prompt
if [ -d .git ] || [ -f .git ]; then
branch=$(git branch --show-current 2>/dev/null) || true
remote=$(git config --get branch.$branch.remote 2>/dev/null) || true
url=$(git remote get-url $remote 2>/dev/null) || true
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[33;1m [GIT BRANCH:> $branch >> $url]\033[0m"
elif [ -d .hg ]; then
hg=$(hg branch 2>/dev/null) || true
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[33;1m [HG BRANCH:> $hg]\033[0m"
elif [ -d .svn ]; then
svn=$(svn info 2>/dev/null | awk '/^URL: /{print $2}') || true
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[33;1m [SVN URL:> $svn]\033[0m"
else
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"
fi
lf -remote "send $id set promptfmt \"$fmt\""
# update terminal name
printf "\033]0; ${PWD/#$HOME/\~}\007" > /dev/tty
}}
on-cd
# search all files for text
cmd fzf_search ${{
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\""
}}
map ? :fzf_search
# Use rsync for paste
cmd paste &{{
set -- $(cat ~/.local/share/lf/files)
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
;;
move) mv -n -- "$@" .;;
esac
rm ~/.local/share/lf/files
lf -remote "send clear"
}}
# follow symlinks
cmd follow_link %{{
lf -remote "send ${id} select '$(readlink $f)'"
}}
map gL follow_link
# move selected files to new folder
cmd newfold ${{
set -f
printf "Directory name: "
read newd
mkdir -- "$newd"
mv -- $fx "$newd"
}}
map <a-n> newfold
cmd open-with-gui &$@ $fx ## opens with a gui application outside lf client
cmd open-with-cli $$@ $fx ## opens with a cli application inside lf client
map O push :open-with-gui<space> ## input application
map o push :open-with-cli<space> ## input application

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# From https://github.com/gokcehan/lf/wiki/Previews#with-kitty-and-pistol
kitty +kitten icat --clear --stdin no --silent --transfer-mode file < /dev/null > /dev/tty

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
# From https://github.com/gokcehan/lf/wiki/Previews#with-kitty-and-pistol
# Includes fallback for non-images
file=$1
w=$2
h=$3
x=$4
y=$5
case "$(file -Lb --mime-type -- "$1")" in
image/*)
kitty +kitten icat --silent --stdin no --transfer-mode file --place "${w}x${h}@${x}x${y}" "$file" < /dev/null > /dev/tty
exit 1
;;
*)
cat "$1"
;;
esac

View file

@ -85,7 +85,7 @@ riverctl spawn "swayidle -w timeout 300 'swaylock -f --fade-in=1' timeout 600 'w
# Applications
riverctl map normal Super D spawn fuzzel
riverctl map normal Super Return spawn $TERMINAL
riverctl map normal Super E spawn "$TERMINAL -e ranger"
riverctl map normal Super E spawn "$TERMINAL -e lf"
riverctl map normal Super+Shift E spawn thunar
riverctl map normal Control+Shift Escape spawn "$TERMINAL -e btop"