1
0
Fork 0

rework shortcuts

This commit is contained in:
Luca Bilke 2024-04-09 18:25:23 +02:00
parent 9823dc15dc
commit 5cfe0f5a0b
5 changed files with 64 additions and 38 deletions

View File

@ -4,7 +4,7 @@ ch $XDG_CACHE_HOME
cf $XDG_CONFIG_HOME
dt $XDG_DATA_HOME
st $XDG_STATE_HOME
bn $HOME/.local/bin
sc $HOME/.local/bin
le $HOME/.local/libexec
mn /mnt
co $XDG_DOCUMENTS_DIR/dev

View File

@ -1,17 +1,4 @@
# Basic vars
set ratios 1:2:5
set shellopts '-eu'
set ifs "\n"
set findlen 1
set scrolloff 10
set icons
set wrapscroll
set period 1
set cursorpreviewfmt "\033[7;90m"
set promptfmt # this is set in a function later
set previewer ~/.config/lf/preview/ueberzug
set cleaner ~/.config/lf/preview/clean
# Functions
# HACK: This is needed to trigger the opening function of the taolf nvim plugin
cmd open ${{
set +u
@ -252,24 +239,40 @@ cmd new_lf_term &{{
$TERMINAL -e lfX -command "$mapcmd"
}}
&{{
set +u
# previewer=ueberzug
# [ -n "$TMUX" ] && previewer=ueberzug
# [ -n "$VIM" ] && previewer=chafa
# lf -remote "send $id set_previewer $previewer"
# Setup
# Clean up tags that don't exist anymore
# BUG: causes an obscure lf crash when tags are empty
# echo "$(
# while read -r l; do
# file=$(echo "$l" | cut -d ':' -f 1)
# [ -e "$file" ] && echo "$l"
# done <"${XDG_DATA_HOME}/lf/tags"
# )\n" >"${XDG_DATA_HOME}/lf/tags"
}}
# &{{
# set +u
# previewer=ueberzug
# [ -n "$TMUX" ] && previewer=ueberzug
# [ -n "$VIM" ] && previewer=chafa
# lf -remote "send $id set_previewer $previewer"
#
# # Clean up tags that don't exist anymore
# # BUG: causes an obscure lf crash when tags are empty
# echo "$(
# while read -r l; do
# file=$(echo "$l" | cut -d ':' -f 1)
# [ -e "$file" ] && echo "$l"
# done <"${XDG_DATA_HOME}/lf/tags"
# )\n" >"${XDG_DATA_HOME}/lf/tags"
# }}
on-cd
# Basic vars
set ratios 1:2:5
set shellopts '-eu'
set ifs "\n"
set findlen 1
set scrolloff 10
set icons
set wrapscroll
set period 1
set cursorpreviewfmt "\033[7;90m"
set promptfmt # this is set in a function later
set previewer ~/.config/lf/preview/ueberzug
set cleaner ~/.config/lf/preview/clean
# Bindings
clearmaps
@ -277,8 +280,8 @@ map <esc> quit
map <space> :toggle; down
map <enter> shell
map <a-enter> shell-wait
map <tab><tab> fzf 'Shortcuts' 'cat $XDG_DATA_HOME/lf/shortcuts 2>/dev/null' ':' '1' '2' '85%' '^'
map <tab><space> find_project
# map <tab><tab> fzf 'Shortcuts' 'cat $XDG_DATA_HOME/lf/shortcuts 2>/dev/null' ':' '1' '2' '85%' '^'
map <tab><tab> find_project
map <tab>t fzf 'Tags' 'cat $XDG_DATA_HOME/lf/tags 2>/dev/null' ':' '1' '1' '50%'
map <tab>m fzf 'Marks' 'cat $XDG_DATA_HOME/lf/marks 2>/dev/null' ':' '1' '2' '85%' '^'
map <tab>f fzf 'Files' 'find -L $PWD' ':' '1' '1' '50%'
@ -308,7 +311,8 @@ map <c-g> lazygit
map <a-g> $gdu
map gg top
map g/ cd /
map g~ cd
# NOTE: g* is used for shortcuts generated by the shortcuts script
source ~/.config/lf/shortcuts
map G bottom
map h updir
map i :rename; cmd-end # rename from end

18
.config/lf/shortcuts Normal file
View File

@ -0,0 +1,18 @@
map gh cd /home/luca
map gch cd /home/luca/.cache
map gcf cd /home/luca/.config
map gdt cd /home/luca/.local/share
map gst cd /home/luca/.local/state
map gsc cd /home/luca/.local/bin
map gle cd /home/luca/.local/libexec
map gmn cd /mnt
map gco cd /home/luca/Documents/dev
map gdl cd /home/luca/Downloads
map gdm cd /home/luca/Documents
map gdk cd /home/luca/Desktop
map gms cd /home/luca/Music
map gpc cd /home/luca/Pictures
map gvd cd /home/luca/Videos
map gds cd /home/luca/.local/share/stow/dots
map glg cd /home/luca/.local/log
map gsv cd /home/luca/.local/sv

View File

@ -3,7 +3,7 @@ hash -d ch=/home/luca/.cache
hash -d cf=/home/luca/.config
hash -d dt=/home/luca/.local/share
hash -d st=/home/luca/.local/state
hash -d bn=/home/luca/.local/bin
hash -d sc=/home/luca/.local/bin
hash -d le=/home/luca/.local/libexec
hash -d mn=/mnt
hash -d co=/home/luca/Documents/dev

View File

@ -5,7 +5,8 @@ bmdirs="$XDG_CONFIG_HOME/directories"
# Outputs
zsh_named_dirs="$ZDOTDIR/configs/hashes"
lf_dirs="$XDG_DATA_HOME/lf/shortcuts"
# lf_dirs="$XDG_DATA_HOME/lf/shortcuts"
lf_maps="$XDG_CONFIG_HOME/lf/shortcuts"
# TODO: Finish this function LOL
# find_marker() {
@ -32,20 +33,21 @@ clean() {
}
write_dirs_tmp() {
mkdir -p /tmp/shortcuts
while IFS= read -r line; do
shortcut=$(echo "$line" | cut -d' ' -f1)
path=$(echo "$line" | cut -d' ' -f2)
path=$(eval "echo $path")
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"/tmp/shortcuts/zsh_named_dirs"
printf "%s:%s\n" "$shortcut" "$path" >>"/tmp/shortcuts/lf_dirs"
# printf "%s:%s\n" "$shortcut" "$path" >>"/tmp/shortcuts/lf_dirs"
printf "map g%s cd %s\n" "$shortcut" "$path" >>"/tmp/shortcuts/lf_maps"
done
}
apply_tmp() {
cat /tmp/shortcuts/zsh_named_dirs >"$zsh_named_dirs"
cat /tmp/shortcuts/lf_dirs >"$lf_dirs"
# cat /tmp/shortcuts/lf_dirs >"$lf_dirs"
cat /tmp/shortcuts/lf_maps >"$lf_maps"
}
read_file() {
@ -55,6 +57,8 @@ read_file() {
trap clean EXIT
mkdir -p /tmp/shortcuts
read_file "$bmdirs" | write_dirs_tmp
apply_tmp