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

39 lines
906 B
Plaintext
Raw Normal View History

2022-07-04 21:36:33 +02:00
#!/bin/sh
2024-04-13 18:02:16 +02:00
zsh=$ZDOTDIR/configs/hashes
lf=$XDG_CONFIG_HOME/lf/shortcuts
2024-04-16 10:13:40 +02:00
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-04-16 10:13:40 +02:00
printf "%s\n%s\n%s\n" "-- NOTE: Managed by shortcuts script" "---@class config.shortcuts" "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)
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"
printf " g%s = \"%s\",\n" "$shortcut" "$path" >>"$nvim"
2024-03-12 22:41:46 +01:00
done
}
2024-04-12 18:49:52 +02:00
filter() {
input=$1
sed 's/#.*//;/^$/d;s/ \+/ /g' "$input"
2024-03-12 22:41:46 +01:00
}
clean
2024-04-12 18:49:52 +02:00
filter "$XDG_CONFIG_HOME/directories" | write
2024-04-13 18:02:16 +02:00
finalize