Files
nix/users/blake/dots/core/lf/lfrc

115 lines
2.2 KiB
Plaintext

# blake's lf config
# --- folder specific ---
# timesheets show recent first
setlocal ~/documents/holocron/work/nhc/timesheets/2024/ reverse
# --- options ---
# file previews
set previewer ctpv
set cleaner ctpvclear
&ctpv -s $id
&ctpvquit $id
# mouse
set mouse true
# search
set ignorecase true
# --- mappings ---
# shortcuts
map gb cd /holocron
map gn cd ~/.nix
# navigation
map [ half-up
map ] half-down
# files & archives
map ad mkdir
map af mkfile
map ab mkbak
map ae extract
map aa archive
# trash
map gt cd ~/.local/share/Trash/files
map <delete> trash
map <s-delete> $trash restore
# --- functions ---
# extract any archive
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
}}
cmd archive %{{
echo "enter archive name: " ; read archive_name
if [ -z "$archive_name" ]; then
echo "No archive name provided."
exit 1
fi
IFS="$(printf '\n\t')"
file_list=()
for x in $fx; do
file_list+=("$x")
done
case "$archive_name" in
*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar cjf "$archive_name" "${file_list[@]}" ;;
*.tar.gz|*.tgz) tar czf "$archive_name" "${file_list[@]}" ;;
*.tar.xz|*.txz) tar cJf "$archive_name" "${file_list[@]}" ;;
*.zip) zip -r "$archive_name" "${file_list[@]}" ;;
*.rar) rar a "$archive_name" "${file_list[@]}" ;;
*.7z) 7z a "$archive_name" "${file_list[@]}" ;;
*) echo "Unsupported archive format" ;;
esac
}}
# move files to trash
cmd trash %IFS="$(printf '\n\t')"; trash put $fx
# make a directory
cmd mkdir %{{
echo "enter directory name: " ; read dir
if [ -n "$dir" ]; then
mkdir -p "$dir" && echo "'$dir' created."
else
echo "no dir name provided"
fi
}}
# make a file
cmd mkfile %{{
echo "enter file name: " ; read file
if [ -n "$file" ]; then
touch "$file" && echo "'$file' created."
else
echo "no file name provided"
fi
}}
# make backup
cmd mkbak %{{
for x in $fx; do
cp -r $x $x.bak
done
}}