From 1eb7a1a53b0e3c391635a0f643ed2aa286a10993 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Sun, 4 Apr 2021 20:16:19 +0530 Subject: added some custom functions --- .config/lf/lfrc | 77 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 12 deletions(-) (limited to '.config/lf/lfrc') diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 05ec490..37d49cc 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -10,34 +10,87 @@ set shell zsh # unmap keys map y map d +map m -# keybindings +# keymappings # rename map C rename # at the end map c push C map push C # new rename +# map B bulkrename +# cut/copy/paste map yy copy map dd cut +map D delete + +# new files/directories +map md mkdir +map mf mkfile + +# misc map H set hidden! +map reload # custom commands +cmd open ${{ + case $(file --mime-type "$f" -bL) in + text/*|application/json) $EDITOR "$f";; + *) xdg-open "$f" ;; + esac +}} cmd mkdir ${{ - echo "Directory Name: " + printf "Directory Name: " read ans mkdir $ans }} -# cmd copyto ${{ -# clear; tput cup $(($(tput lines)/3)); tput bold -# set -f -# clear; echo "Copy to where?" -# dest="$(cut -d' ' -f2- ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|' )" && -# for x in $fx; do -# eval cp -ivr \"$x\" \"$dest\" -# done && -# notify-send "📋 File(s) copied." "File(s) copies to $dest." -# }} +cmd mkfile ${{ + printf "File Name: " + read ans + $EDITOR $ans +}} + +cmd sudomkfile ${{ + printf "File Name: " + read ans + sudo $EDITOR $ans +}} + +cmd chmod ${{ + printf "Mode Bits: " + read ans + + for file in "$fx" + do + chmod $ans $file + done + + lf -remote 'send reload' +}} + +# archive bindings +cmd unarchive ${{ + case "$f" in + *.zip) unzip "$f" ;; + *.tar.gz) tar -xzvf "$f" ;; + *.tar.bz2) tar -xjvf "$f" ;; + *.tar) tar -xvf "$f" ;; + *) echo "Unsupported format" ;; + esac +}} + +cmd zip %zip -r "$f" "$f" +cmd tar %tar cvf "$f.tar" "$f" +cmd targz %tar cvzf "$f.tar.gz" "$f" +cmd tarbz2 %tar cjvf "$f.tar.bz2" "$f" + +# archive mappings +map az zip +map at tar +map ag targz +map ab targz +map au unarchive -- cgit v1.2.3