Add new functions to lfrc

This commit is contained in:
mintycube 2024-07-05 07:01:24 +05:00
parent dc91d6d439
commit e228e46124
3 changed files with 30 additions and 42 deletions

View File

@ -8,16 +8,15 @@ set period 1
set sortby ext set sortby ext
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
set promptfmt "\033[32m \033[35;1m%d\033[0m\033[1m%f\033[0m" set promptfmt "\033[32m \033[35;1m%d\033[0m\033[1m%f\033[0m"
# set cleaner '~/.config/lf/cleaner'
# set previewer '~/.config/lf/scope'
set autoquit true set autoquit true
# set cursorpreviewfmt "\033[7m"
# Previewer
set previewer ctpv set previewer ctpv
set cleaner ctpvclear set cleaner ctpvclear
&ctpv -s $id &ctpv -s $id
&ctpvquit $id &ctpvquit $id
# cmds/functions
cmd on-cd &{{ cmd on-cd &{{
printf "\033]0; $PWD\007" > /dev/tty printf "\033]0; $PWD\007" > /dev/tty
export STARSHIP_SHELL= export STARSHIP_SHELL=
@ -27,7 +26,6 @@ cmd on-cd &{{
on-cd on-cd
# cmds/functions
cmd open ${{ cmd open ${{
case $(file --mime-type "$(readlink -f $f)" -b) in case $(file --mime-type "$(readlink -f $f)" -b) in
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;;
@ -70,15 +68,12 @@ cmd live_server ${{
setsid -f live-server "$PWD" setsid -f live-server "$PWD"
}} }}
cmd ff $ff "$(echo $*)"
cmd extract ${{ cmd extract ${{
clear; tput cup $(($(tput lines)/3)); tput bold clear; tput cup $(($(tput lines)/3)); tput bold
set -f set -f
printf "%s\n\t" "$fx" printf "%s\n\t" "$fx"
printf "extract?[y/N]" ans=$(echo -e "Cancel\nOk" | fzf --prompt="Extract?" --ansi --border=rounded --margin=0,35% --no-info --height=7)
read ans [ $ans = "Ok" ] && {
[ $ans = "y" ] && {
case $fx in case $fx in
*.tar.bz2) tar xjf $fx ;; *.tar.bz2) tar xjf $fx ;;
*.tar.gz) tar xzf $fx ;; *.tar.gz) tar xzf $fx ;;
@ -100,9 +95,8 @@ cmd delete ${{
clear; tput cup $(($(tput lines)/3)); tput bold clear; tput cup $(($(tput lines)/3)); tput bold
set -f set -f
printf "%s\n\t" "$fx" printf "%s\n\t" "$fx"
printf "delete?[y/N]" ans=$(echo -e "Cancel\nOk" | fzf --prompt="Delete?" --ansi --border=rounded --margin=0,35% --no-info --height=7)
read ans [ $ans = "Ok" ] && trash-put $fx
[ $ans = "y" ] && rm -rf -- $fx
}} }}
cmd moveto ${{ cmd moveto ${{
@ -127,8 +121,6 @@ cmd copyto ${{
notify-send "📋 File(s) copied." "File(s) copies to $dest." notify-send "📋 File(s) copied." "File(s) copies to $dest."
}} }}
cmd setbg "$1"
cmd bulkrename ${{ cmd bulkrename ${{
tmpfile_old="$(mktemp)" tmpfile_old="$(mktemp)"
tmpfile_new="$(mktemp)" tmpfile_new="$(mktemp)"
@ -156,6 +148,7 @@ cmd git_branch ${{
lf -remote "send $id updir" lf -remote "send $id updir"
lf -remote "send $id cd \"$pwd_shell\"" lf -remote "send $id cd \"$pwd_shell\""
}} }}
cmd git_root ${{ cmd git_root ${{
root="$(git rev-parse --show-toplevel 2>/dev/null)" root="$(git rev-parse --show-toplevel 2>/dev/null)"
if [ -n "$root" ]; then if [ -n "$root" ]; then
@ -166,11 +159,6 @@ cmd git_root ${{
exit 1 exit 1
fi fi
}} }}
map gb :git_branch
map gr :git_root
map gp ${{clear; git pull --rebase || true; echo "press ENTER"; read ENTER}}
map gs ${{clear; git status; echo "press ENTER"; read ENTER}}
map gl ${{clear; git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit}}
cmd sanitize ${{ cmd sanitize ${{
set -f set -f
@ -209,10 +197,9 @@ cmd change_preview %{{
fi fi
}} }}
cmd ff $ff "$(echo $*)"
cmd share $curl -F"file=@$fx" -Fexpires=24 https://0x0.st | xclip -selection c cmd share $curl -F"file=@$fx" -Fexpires=24 https://0x0.st | xclip -selection c
cmd setbg "$1"
map zp toggle_preview
map ze change_preview
# Bindings # Bindings
map <esc> :quit map <esc> :quit
@ -231,13 +218,12 @@ map C copyto
map M moveto map M moveto
map <c-n> push :ff<space> map <c-n> push :ff<space>
map <c-r> reload map <c-r> reload
map <c-s> set hidden! map <c-s> share
map <enter> shell map <enter> shell
map x $$f map x $$f
map X !$f map X !$f
map o &mimeopen "$f" map o &mimeopen "$f"
map O $mimeopen --ask "$f" map O $mimeopen --ask "$f"
map a :rename; cmd-end # at the very end map a :rename; cmd-end # at the very end
map c push A<c-u> # new rename map c push A<c-u> # new rename
map I :rename; cmd-home # at the very beginning map I :rename; cmd-home # at the very beginning
@ -245,18 +231,19 @@ map i :rename # before extension
map A :rename; cmd-right # after extension map A :rename; cmd-right # after extension
map B bulkrename map B bulkrename
map b $setbg $f map b $setbg $f
map <c-e> down map <c-e> down
map <c-y> up map <c-y> up
map V push :!nvim<space> map V push :!nvim<space>
map W $setsid -f $TERMINAL >/dev/null 2>&1 map W $setsid -f $TERMINAL >/dev/null 2>&1
map . set hidden! map . set hidden!
map U $printf "%s" "$fx" | xclip -selection clipboard map U $printf "%s" "$fx" | xclip -selection clipboard
map u $printf "%s" "$fx" | sed 's/.*\///' | xclip -selection clipboard map u $printf "%s" "$fx" | sed 's/.*\///' | xclip -selection clipboard
map T $sxiv -t "$(pwd)" # opens thumbnail mode map T $sxiv -t "$(pwd)" # opens thumbnail mode
map <c-l> unselect map <c-l> unselect
map zp toggle_preview
# Source Bookmarks map ze change_preview
source "~/.config/lf/shortcutrc" map gb :git_branch
map gr :git_root
map gp ${{clear; git pull --rebase || true; echo "press ENTER"; read ENTER}}
map gs ${{clear; git status; echo "press ENTER"; read ENTER}}
map gl ${{clear; git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit}}

View File

@ -50,7 +50,7 @@ return {
branch = "harpoon2", branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
keys = { keys = {
{ "<leader>a", function() require("harpoon"):list():add() end, desc = "Add to list" }, { "<leader>a", function() require("harpoon"):list():add() end, desc = "Add to harpoon" },
{ "<leader>h", function() require("harpoon").ui:toggle_quick_menu(require("harpoon"):list()) end, desc = "harpoon ui" }, { "<leader>h", function() require("harpoon").ui:toggle_quick_menu(require("harpoon"):list()) end, desc = "harpoon ui" },
{ "<leader>1", function() require("harpoon"):list():select(1) end, desc = "Harpoon Select 1" }, { "<leader>1", function() require("harpoon"):list():select(1) end, desc = "Harpoon Select 1" },
{ "<leader>2", function() require("harpoon"):list():select(2) end, desc = "Harpoon Select 2" }, { "<leader>2", function() require("harpoon"):list():select(2) end, desc = "Harpoon Select 2" },

View File

@ -1,14 +1,15 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Command for notes scratchpad used in dwm # Command for notes scratchpad used in dwm
fd --color=always \ selection=$(fd --color=always \
--base-directory ~/notes \ --base-directory ~/notes \
-e md -e txt -e qalc \ -e md -e txt -e qalc \
| fzf \ | fzf \
--ansi \ --ansi \
--prompt="Notes  " \ --prompt="Notes  " \
--margin="10%,5%" \ --margin="10%,5%" \
--no-info --height=100% --scrollbar="" \ --no-info --height=100% --scrollbar="" \
--preview="glow ~/notes/{}" \ --preview="glow ~/notes/{}" \
--preview-window="border-left" \ --preview-window="border-left")
| xargs -r nvim
[ -n "$selection" ] && nvim ~/notes/"$selection"