34 lines
890 B
Bash
Executable File
34 lines
890 B
Bash
Executable File
#!/bin/sh
|
|
|
|
zsh=${ZDOTDIR}/configs/hashes
|
|
lf=${XDG_CONFIG_HOME}/lf/shortcuts
|
|
nvim=${XDG_CONFIG_HOME}/nvim/lua/config/shortcuts.lua
|
|
|
|
clean() {
|
|
echo "# NOTE: Managed by shortcuts script" >"$zsh"
|
|
echo "# NOTE: Managed by shortcuts script" >"$lf"
|
|
printf "%s\n%s\n%s\n" "-- NOTE: Managed by shortcuts script" "---@class config.shortcuts" "return {" >"$nvim"
|
|
}
|
|
|
|
finalize() {
|
|
echo "}" >>"$nvim"
|
|
}
|
|
|
|
write() {
|
|
while IFS= read -r line; do
|
|
shortcut=$(echo "$line" | cut -d' ' -f1)
|
|
path=$(echo "$line" | cut -d' ' -f2)
|
|
path=$(eval "echo $path" | sed "s|${HOME}|~|g")
|
|
|
|
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"
|
|
done
|
|
}
|
|
|
|
clean
|
|
|
|
sed 's/#.*//;/^$/d;s/ \+/ /g' <"${XDG_CONFIG_HOME}/directories" | write
|
|
|
|
finalize
|