aboutsummaryrefslogtreecommitdiff
path: root/.config/lf/lfrc
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-08 16:41:50 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-08 16:41:50 +0530
commit6e9091e26593a145e6350a01bad53f26acea75a1 (patch)
tree2d841fa503d20560d2f6e57a33c8ded65d817be8 /.config/lf/lfrc
parentf94c1202afce479d61ff833d8cd05fe417c98288 (diff)
pushing all the dotfiles again
Diffstat (limited to '.config/lf/lfrc')
-rwxr-xr-x.config/lf/lfrc178
1 files changed, 178 insertions, 0 deletions
diff --git a/.config/lf/lfrc b/.config/lf/lfrc
new file mode 100755
index 0000000..029cc8f
--- /dev/null
+++ b/.config/lf/lfrc
@@ -0,0 +1,178 @@
+# Basic Settings
+set previewer ~/.config/lf/preview
+set preview true
+# set drawbox true
+# set icons true
+set ignorecase true
+set scrolloff 1
+set shell zsh
+
+# unmap keys
+map y
+map d
+map m
+
+# keymappings
+# rename
+map C rename # at the end
+map c push C<a-b><a-b><a-f>
+map <c-c> push C<c-u> # new rename
+map B bulk-rename # fix this
+
+# lf commands
+map H set hidden!
+map <c-r> reload
+
+# cut/copy/paste
+map p paste
+map yy copy
+map dd cut
+map D delete
+
+# new files/directories
+map md push :mkdir<space>
+map mf push :mkfile<space>
+map mF push :touch<space>
+
+# opening files
+map o push :open-with<space>
+map L open_ext
+map P share
+
+# selecting files/globs
+map t toggle
+
+# custom commands
+cmd open ${{
+ case $(file --mime-type "$f" -bL) in
+ text/*|application/json) $EDITOR "$f";;
+ *) xdg-open "$f" ;;
+ esac
+}}
+
+# open in another terminal
+cmd open_ext ${{
+ case $(file --mime-type "$f" -bL) in
+ text/*|application/json) $TERMINAL "-e" $EDITOR "$f";;
+ *) xdg-open "$f" ;;
+ esac
+}}
+
+# cmd mkdir ${{
+# set -f
+# printf "Directory Name: "
+# read ans
+# mkdir $ans
+# }}
+
+# cmd mkfile ${{
+# printf "File Name: "
+# read ans
+# $EDITOR $ans
+# }}
+
+# cmd mkdir %mkdir "$@"
+cmd mkdir %{{
+ IFS=" "
+ mkdir -p -- "$*"
+ lf -remote "send $id select \"$*\""
+}}
+cmd mkfile %nvim "$@"
+# cmd touch %touch "$@"
+cmd touch %{{
+ IFS=" "
+ touch "$*"
+ lf -remote "send $id select \"$*\""
+}}
+
+cmd chmod ${{
+ printf "Mode Bits: "
+ read ans
+
+ for file in "$fx"
+ do
+ chmod $ans $file
+ done
+
+ lf -remote 'send reload'
+}}
+
+cmd open-with %"$@" $fx
+cmd share $curl -F"file=@$fx" https://0x0.st | xclip -selection c
+
+# bulk rename non-hidden or selected files
+# 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"
+# }}
+
+# override paste with cp-p
+cmd paste $cp-p --lf-paste $id
+
+# 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
+
+# this runs on each directory change
+cmd on-cd &{{
+ # display git repository status in your prompt
+ source /usr/share/git/completion/git-prompt.sh
+ GIT_PS1_SHOWDIRTYSTATE=auto
+ GIT_PS1_SHOWSTASHSTATE=auto
+ GIT_PS1_SHOWUNTRACKEDFILES=auto
+ GIT_PS1_SHOWUPSTREAM=auto
+ GIT_PS1_COMPRESSSPARSESTATE=auto
+ git=$(__git_ps1 " [GIT BRANCH:> %s]") || true
+ fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[33;1m$git\033[0m"
+ lf -remote "send $id set promptfmt \"$fmt\""
+
+ # update window title
+ printf "\033]0; $PWD\007" > /dev/tty
+}}
+
+# set number of columns depending
+# on window size on startup
+# %{{
+# w=$(tput cols)
+# if [ $w -le 80 ]; then
+# lf -remote "send $id set ratios 1:2"
+# elif [ $w -le 160 ]; then
+# lf -remote "send $id set ratios 1:2:3"
+# else
+# lf -remote "send $id set ratios 1:2:3:5"
+# fi
+# }}