aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2022-10-31 00:37:00 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2022-10-31 00:37:00 +0100
commit842adfee9c14d44ffd672a7608a73d36bf50b554 (patch)
treeb507385aa13505d6b0e6a899f3bc0bc93ef137c3
parent3d284d2aad54269efa884b7a0b4fcc20e197b37d (diff)
downloaddotfiles-842adfee9c14d44ffd672a7608a73d36bf50b554.tar.gz
add install.sh add command to easily add new configs
-rwxr-xr-xinstall.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/install.sh b/install.sh
index b5a7b38..31051b2 100755
--- a/install.sh
+++ b/install.sh
@@ -42,6 +42,8 @@ COMMANDS
install [CONFIG ...]
install configurations. if none are provided,
a selection menu is showm.
+ add PATH
+ Add PATH to managed configs
hk
perform housekeeping functions
EOF
@@ -64,6 +66,25 @@ case $CMD in
housekeeping;;
hk)
housekeeping;;
+ add)
+ test -e "$1" || fail 1 "Target file not found: $1"
+
+ TARGET=$(realpath "--relative-to=$HOME" "$1")
+ NAME=$(basename "$TARGET")
+ RELPATH=$(dirname "$TARGET")
+
+ # NOTE: This does not check SETS. Could be a problem
+ test -n "${CONFIGS[$NAME]}" && fail 1 "An object with the same name is already managed."
+
+ cp -r "$1" ./ || fail 1 "Failed to copy configuration"
+ echo "$NAME;$RELPATH" >> config.csv
+ # This would need a reload
+ #choose_target "$NAME"
+
+ echo "Config was isntalled successfully."
+ echo "It can now be installed with $0 install $NAME"
+ echo "The following files were changed: config.csv $NAME"
+ ;;
*)
echo Invalid command: "$CMD"
exit 1