New cleaner nvim config. Added config for LF

This commit is contained in:
Thomas Naderer
2024-12-25 09:58:39 +01:00
parent 741e32a1ff
commit 46ae676593
10 changed files with 1345 additions and 136 deletions

5
lf/cleaner Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
if [ -n "$FIFO_UEBERZUG" ]; then
printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG"
fi

377
lf/icons Normal file
View File

@@ -0,0 +1,377 @@
# 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  # STICKY_OTHER_WRITABLE
ow  # OTHER_WRITABLE
st  # 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
# disable some default filetype icons, let them choose icon by filename
# ln  # LINK
# or  # ORPHAN
# tw # STICKY_OTHER_WRITABLE
# ow # OTHER_WRITABLE
# st # STICKY
# di  # DIR
# pi # FIFO
# so # SOCK
# bd # BLK
# cd # CHR
# su # SETUID
# sg # 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 

391
lf/lfrc Normal file
View File

@@ -0,0 +1,391 @@
#-----------------------------------------------------------------------------#
# File: ~/.config/lf/lfrc (archlinux @ 'silent')
# Date: Thu 15 Mar 2022 12:05
# Update: Mon 08 Jul 2024 22:04
# Owner: fvb - freekvb@gmail.com - https://freekvb.github.io/fvb/
#-----------------------------------------------------------------------------#
## Based on lfrc Luke Smith & Brodie Robertson -------------------------------#
# Note on Image Previews
# For those wanting image previews, like this system, there are four steps to
# set it up. These are done automatically for LARBS users, but I will state
# them here for others doing it manually.
#
# 1. ueberzug must be installed.
# 2. The scope file (~/.config/lf/scope for me), must have a command similar to
# mine to generate ueberzug images.
# 3. A `set cleaner` line as below is a cleaner script.
# 4. lf should be started through a wrapper script (~/.local/bin/lfub for me)
# that creates the environment for ueberzug. This command can be be aliased
# in your shellrc (`alias lf="lfub") or if set to a binding, should be
# called directly instead of normal lf.
## basic vars ----------------------------------------------------------------#
set ratios '10:15:20'
set hidden
set ignorecase
set number
set relativenumber
set cursorpreviewfmt " "
set info size
set dircounts
set shell sh
set shellopts '-eu'
set ifs "\n"
set scrolloff 10
set wrapscroll
set icons
set period 1
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
set cleaner '~/.config/lf/cleaner'
set previewer '~/.config/lf/scope'
set promptfmt "\033[37;1m%d\033[0m\033[37;1m%f\033[0m"
## custom functions ----------------------------------------------------------#
cmd on-cd &{{
# '&' commands run silently in background (which is what we want here),
# but are not connected to stdout.
# To make sure our escape sequence still reaches stdout we pipe it to /dev/tty
printf "\033]0; $(pwd | sed "s|$HOME|~|") - lf\007" > /dev/tty
}}
# also run at startup
on-cd
cmd open ${{
case $(file --mime-type "$f" -bL) in
text/*|application/json) $EDITOR "$fx";;
video/*|application/pdf) xdg-open "$f" & disown;;
audio/*) mpv --audio-display=no $f ;;
audio/*) ffplay -nodisp -autoexit $f ;;
image/*) feh -F $f & disown;;
*) for f in "$fx"; do xdg-open "$f"> /dev/null 2> /dev/null & done;;
esac
}}
# make new directory
cmd mkdir %{{
if [ "$1" ]; then
mkdir -p -- "$@" && lf -remote "send $id select \"$1\""
fi
}}
#cmd mkdir ${{
# set -f
# printf "\nDirectory Name: "
# read ans
# mkdir $ans
#}}
# make new file
cmd mkfile ${{
set -f
printf "\nFile Name: "
read ans
$EDITOR $ans
}}
# make new 'root' file
cmd doasmkfile ${{
set -f
printf "\nFile Name: "
read ans
doas $EDITOR $ans
}}
# make new script
cmd mkscript ${{
set -f
printf "\nFile Name: "
read ans
touch ~/Scripts/"$ans"
chmod +x ~/Scripts/"$ans"
$EDITOR ~/Scripts/"$ans"
}}
# change file permissions
cmd chmod ${{
set -f
printf "\nMode Bits: "
read ans
for file in "$fx"
do
chmod $ans $file
done
lf -remote 'send reload'
}}
# make file executable
cmd chmodx ${{
for file in "$fx"
do
chmod +x $file
done
lf -remote 'send reload'
}}
# jump with fzf
cmd fzf_jump ${{
res="$(find . -maxdepth 3 | fzf --reverse --header='Jump to location')"
if [ -f "$res" ]; then
cmd="select"
elif [ -d "$res" ]; then
cmd="cd"
fi
lf -remote "send $id $cmd \"$res\""
}}
# delete current file or selected files (prompting)
cmd delete ${{
set -f
printf "\n$fx\n"
printf "Delete? [y/n] "
read ans
[ $ans = "y" ] && rm -rf $fx
}}
# trash cli bindings
cmd trash ${{
files=$(printf "$fx" | tr '\n' ';')
while [ "$files" ]; do
# extract the substring from start of string up to delimiter.
# this is the first "element" of the string.
file=${files%%;*}
trash-put "$(basename "$file")"
# if there's only one element left, set `files` to an empty string.
# this causes us to exit this `while` loop.
# else, we delete the first "element" of the string from files, and move onto the next.
if [ "$files" = "$file" ]; then
files=''
else
files="${files#*;}"
fi
done
}}
cmd clear_trash %trash-empty
cmd restore_trash ${{
trash-restore
}}
## trash
#$mkdir -p ~/.cache/lf/trash
#cmd trash $IFS="`printf '\n\t'`"; mv -f $fx ~/.cache/lf/trash
# 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
}}
# symlinks
# yy (select for copy) and P to paste soft-link
# cc (select for cut) and P to paste hard-link
cmd link %{{
set -- $(cat ~/.local/share/lf/files)
mode="$1"
shift
if [ "$#" -lt 1 ]; then
lf -remote "send $id echo no files to link"
exit 0
fi
case "$mode" in
# symbolically copy mode is indicating a soft link
copy) ln -sr -t . -- "$@";;
# while a move mode is indicating a hard link
move) ln -t . -- "$@";;
esac
rm ~/.local/share/lf/files
lf -remote "send clear"
}}
# open terminal
cmd openterm ${{
devour $TERM
}}
# set wallpaper and colorscheme (cli only)
cmd wallcolor %cp "$f" ~/.config/wall.png && wal -i "$f"
# set wallpaper and colorscheme (cli only) when running dwm
cmd setwallpaper %cp "$f" ~/.config/wall.png && wal -i "$f" && (cd $HOME/Programs/dwm && rm -f config.h ; doas make clean install) && (cd $HOME/Programs/dmenu && rm -f config.h ; doas make clean install) && xdotool key super+shift+q
# bulk rename
cmd bulkrename $vidir
## bindings ------------------------------------------------------------------#
# remove some defaults
map "'"
map '"'
map ,
map c
map d
map e
map m
map q
map r
# escape
map <esc> :unselect;clear;
# close
map ,q quit
# map : to ;
map ; read
map gg top
map G bottom
# trash mappings
map dd trash
map ct clear_trash
map rt restore_trash
map DD delete
map cc cut
map yy copy
map p paste
map md push :mkdir<space>
#map md mkdir
map mf mkfile
map ms mkscript
map mF doasmkfile
map ch chmod
map x chmodx
map U unselect
map E extract
map cs wallcolor
map bg setwallpaper
map <enter> shell
map V push :!nvim<space>
map YY $printf "%s" "$fx" | xclip -selection clipboard
map R reload
map C clear
# rename
map cw rename
map B bulkrename
map A rename # at the very end
#map c push A<c-u> # new rename
map I push A<c-a> # at the very beginning
map i push A<a-b><a-b><a-f> # before extention
map a push A<a-b> # after extention
# symlinks
# yy (select for copy) and P to paste soft-link
# cc (select for cut) and P to paste hard-link
map P :link
## file openers
map cv push :!nvim<space>$HOME/.config/lf/lfrc<enter>
map cz push :!nvim<spade>$HOME/.config/zsh/.zshrc<enter>
map of open $f
map ol $$PAGER "$f"
map oq $$BROWSER "$f"
map ot openterm
map ov $$EDITOR "$f"
map odv $doas $EDITOR "$f"
map oz $$READER "$f"
# execute current file (must be executable)
#map x $$f
map X !$f
## fzf
map f $lf -remote "send $id select '$(fzf)'"
map F $vi $(fzf)
map J fzf_jump
## fast navigation
map gh cd ~
#map gD cd ~/Documents
map gD cd ~/Downloads
map gM cd ~/Media
map gN cd ~/Notes
map gi cd ~/Notes/ict
map gt cd ~/Notes/trades
map gp cd ~/Notes/trades/tp
#map gP cd ~/Pictures
map gw cd ~/Pictures/wallpapers
map gP cd ~/Programs
map gS cd ~/Scripts
map gT cd ~/Torrents
map gc cd ~/.config
map gl cd ~/.local
map gs cd ~/.local/share
map g0 cd ~/.local/share/Trash/files
map g/ cd /
map ge cd /etc
map gm cd /mnt
map gu cd /usr
## fast movement
map Mh $mv "$f" ~
map MD $mv "$f" ~/Documents
#map MD $mv "$f" ~/Downloads
map MM $mv "$f" ~/Media
map MN $mv "$f" ~/Notes
map Mi $mv "$f" ~/Notes/ict
map Mt $mv "$f" ~/Notes/trades/tp
map MP $mv "$f" ~/Pictures
map Mw $mv "$f" ~/Pictures/wallpapers
#map MP $mv "$f" ~/Programs
map MS $mv "$f" ~/Scripts
map MT $mv "$f" ~/Torrents
map Mc $mv "$f" ~/.config
map Ml $mv "$f" ~/.local
## fast copy
map Yh $cp "$f" ~
map YD $cp "$f" ~/Documents
#map YD $cp "$f" ~/Downloads
map YM $cp "$f" ~/Media
map YN $cp "$f" ~/Notes
map Yi $cp "$f" ~/Notes/ict
map Yt $cp "$f" ~/Notes/trades/tp
map YP $cp "$f" ~/Pictures
map Yw $cp "$f" ~/Pictures/wallpapers
#map YP $cp "$f" ~/Programs
map YS $cp "$f" ~/Scripts
map YT $cp "$f" ~/Torrents
map Yc $cp "$f" ~/.config
map Yl $cp "$f" ~/.local

44
lf/scope Normal file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
# File preview handler for lf.
set -C -f
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"
image() {
if [ -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"
else
mediainfo "$1"
fi
}
ifub() {
[ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1
}
# Note that the cache file name is a function of file information, meaning if
# an image appears in multiple places across the machine, it will not have to
# be regenerated once seen.
case "$(file --dereference --brief --mime-type -- "$1")" in
image/*) image "$1" "$2" "$3" "$4" "$5" ;;
text/html) lynx -width="$4" -display_charset=utf-8 -dump "$1" ;;
text/troff) man ./ "$1" | col -b ;;
text/* | */xml | application/json) bat --terminal-width "$4" -f "$1" ;;
application/zip) atool --list -- "$1" ;;
audio/* | application/octet-stream) mediainfo "$1" || exit 1;;
video/* )
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
[ ! -f "$CACHE" ] && ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0
image "$CACHE" "$2" "$3" "$4" "$5"
;;
*/pdf)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
[ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
image "$CACHE.jpg" "$2" "$3" "$4" "$5"
;;
*opendocument*) odt2txt "$1" ;;
application/pgp-encrypted) gpg -d -- "$1" ;;
esac
exit 1