lf and linewrap
This commit is contained in:
parent
7094a45d50
commit
60071f5794
3 changed files with 118 additions and 1 deletions
110
.config/lf/lfrc
Normal file
110
.config/lf/lfrc
Normal file
|
@ -0,0 +1,110 @@
|
|||
# interpreter for shell commands
|
||||
set shell zsh
|
||||
set shellopts '-euy'
|
||||
set ifs "\n"
|
||||
set filesep "\n" # default already
|
||||
|
||||
# draw borders
|
||||
set drawbox
|
||||
|
||||
# leave some space at the top and the bottom of the screen
|
||||
set scrolloff 10
|
||||
|
||||
# use enter for shell commands
|
||||
map <enter> shell
|
||||
|
||||
# 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 ${{
|
||||
test -L $f && f=$(readlink -f $f)
|
||||
case $(file --mime-type $f -b) in
|
||||
text/*) $EDITOR $fx;;
|
||||
*) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
|
||||
esac
|
||||
}}
|
||||
|
||||
# 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
|
||||
# (also see 'man mv' for backup/overwrite options)
|
||||
# cmd trash %set -f; mv $fx ~/.trash
|
||||
|
||||
# define a custom 'delete' command
|
||||
# cmd delete ${{
|
||||
# set -f
|
||||
# printf "$fx\n"
|
||||
# printf "delete?[y/n]"
|
||||
# read ans
|
||||
# [ $ans = "y" ] && rm -rf $fx
|
||||
# }}
|
||||
|
||||
# use '<delete>' key for either 'trash' or 'delete' command
|
||||
# map <delete> 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
|
||||
}}
|
||||
|
||||
cmd bulk-rename ${{
|
||||
old="$(mktemp)"
|
||||
new="$(mktemp)"
|
||||
[ -n "$fs" ] && fs="$(ls)"
|
||||
printf '%s\n' "$fs" >"$old"
|
||||
printf '%s\n' "$fs" >"$new"
|
||||
$EDITOR "$new"
|
||||
[ "$(wc -l < "$new")" -ne "$(wc -l < "$old")" ] && exit
|
||||
paste "$old" "$new" | while IFS= read -r names; do
|
||||
src="$(printf '%s' "$names" | cut -f1)"
|
||||
dst="$(printf '%s' "$names" | cut -f2)"
|
||||
if [ "$src" = "$dst" ] || [ -e "$dst" ]; then
|
||||
continue
|
||||
fi
|
||||
mv -- "$src" "$dst"
|
||||
done
|
||||
rm -- "$old" "$new"
|
||||
lf -remote "send $id unselect"
|
||||
}}
|
|
@ -69,3 +69,7 @@
|
|||
|
||||
(add-hook 'css-mode-hook #'rainbow-mode)
|
||||
(setq projectile-project-search-path '("~/src/"))
|
||||
|
||||
;; Auto fill mode
|
||||
(add-hook 'text-mode-hook 'turn-on-auto-fill)
|
||||
(setq-default fill-column 100)
|
||||
|
|
|
@ -4,7 +4,7 @@ if [ -f "/etc/lsb-release" ]; then
|
|||
export IS_MANJARO=`[ $(lsb_release -si 2>&1 || echo 'n/a') = "ManjaroLinux" ] && echo 1`
|
||||
export IS_MANJARO=`[ $(lsb_release -si 2>&1 || echo 'n/a') = "Artix" ] && echo 1`
|
||||
export IS_DEBIAN=`[ $(lsb_release -si 2>&1 || echo 'n/a') = "Debian" ] && echo 1`
|
||||
elif [[ `which apk` ]]; then
|
||||
elif command -v apk > /dev/null 2>&1; then
|
||||
export IS_ALPINE=1
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
export IS_MAC=1
|
||||
|
@ -90,6 +90,9 @@ if command -v colordiff > /dev/null 2>&1; then
|
|||
else
|
||||
alias diff="diff -Nuar"
|
||||
fi
|
||||
if command -v lf > /dev/null 2>&1; then
|
||||
alias ranger="lf"
|
||||
fi
|
||||
|
||||
alias grep='grep --colour=auto'
|
||||
#alias ls='ls --color=auto -h'
|
||||
|
|
Loading…
Add table
Reference in a new issue