1
0
Fork 0
dotfiles/.local/bin/shortcuts

34 lines
845 B
Text
Raw Normal View History

2022-07-04 21:36:33 +02:00
#!/bin/sh
2024-05-23 17:13:05 +02:00
zsh=${ZDOTDIR}/configs/hashes
lf=${XDG_CONFIG_HOME}/lf/shortcuts
nvim=${XDG_CONFIG_HOME}/nvim/lua/config/shortcuts.lua
2024-04-13 18:02:16 +02:00
2024-03-12 22:41:46 +01:00
clean() {
2024-04-13 18:02:16 +02:00
echo "# NOTE: Managed by shortcuts script" >"$zsh"
echo "# NOTE: Managed by shortcuts script" >"$lf"
2024-06-03 13:25:44 +02:00
printf "%s\n%s\n" "-- NOTE: Managed by shortcuts script" "return {" >"$nvim"
2024-04-13 18:02:16 +02:00
}
finalize() {
echo "}" >>"$nvim"
2024-03-12 22:41:46 +01:00
}
2024-04-12 18:49:52 +02:00
write() {
2024-03-12 22:41:46 +01:00
while IFS= read -r line; do
shortcut=$(echo "$line" | cut -d' ' -f1)
2024-03-18 22:42:48 +01:00
path=$(echo "$line" | cut -d' ' -f2)
2024-07-11 13:22:31 +02:00
path=$(eval "echo $path")
2024-03-12 22:41:46 +01:00
2024-04-13 18:02:16 +02:00
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"$zsh"
printf "map g%s cd %s\n" "$shortcut" "$path" >>"$lf"
2024-06-10 23:26:14 +02:00
printf " [\"<c-a>%s\"] = \"%s\",\n" "$shortcut" "$path" >>"$nvim"
2024-03-12 22:41:46 +01:00
done
}
clean
2024-04-12 18:49:52 +02:00
2024-05-23 17:13:05 +02:00
sed 's/#.*//;/^$/d;s/ \+/ /g' <"${XDG_CONFIG_HOME}/directories" | write
2024-04-13 18:02:16 +02:00
finalize