summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-05-08 22:50:01 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2024-05-08 22:50:01 -0400
commitba14f31083e20c8706139dc6ba3ee71610ade91b (patch)
tree73f8c9f51703c7a6b6bd24b8ff6546994ee19948
parent26ec2e5dc6e8c2369ecb34b642db546327a8b7dd (diff)
Make shortcutgen POSIX compliant (replace \s)
-rwxr-xr-x.local/bin/shortcutgen9
1 files changed, 5 insertions, 4 deletions
diff --git a/.local/bin/shortcutgen b/.local/bin/shortcutgen
index 2335a92..fe5ed75 100755
--- a/.local/bin/shortcutgen
+++ b/.local/bin/shortcutgen
@@ -1,5 +1,6 @@
#!/bin/sh
+
# raw (basic processing before converting to specific formats)
# - remove comments
# - remove empty lines
@@ -7,16 +8,16 @@
# - remove trailing whitespace
# Strip comments, remove empty lines, condense spacing, remove trailing whitespace
-raw="$(sed 's/#.*//g;s/,\s*/,/g;/^$/d;s/\s*$//g' <"$XDG_CONFIG_HOME/shortcutrc")"
+raw="$(sed 's/#.*//g;s/,[[:space:]]*/,/g;/^$/d;s/[[:space:]]*$//g' <"${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc")"
# lf (sourced by lfrc)
-echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/map g\2 cd \3/' >"$XDG_CONFIG_HOME/lf/shortcuts"
+echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/map g\2 cd \3/' >"${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcuts"
# Shell aliases (read by zshrc)
-echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/alias g\2="cd \3"/' >"$HOME/.cache/zsh-shortcuts"
+echo "$raw" | sed 's/\(.*\),\(.*\),\(.*\)/alias g\2="cd \3"/' >"${XDG_CACHE_HOME:-$HOME/.cache}/zsh-shortcuts"
# Environment variables (read by .profile)
-echo "$raw" | sed 's/^\(.*\),\(.*\),/export G\U\2=,/;s/,\(.*\)/\1/' >"$HOME/.cache/env-shortcuts"
+echo "$raw" | sed 's/^\(.*\),\(.*\),/export G\U\2=,/;s/,\(.*\)/\1/' >"${XDG_CACHE_HOME:-$HOME/.cache}/env-shortcuts"