scripts: deleted 2 & added config-load & edited some
This commit is contained in:
34
scripts/config-load
Executable file
34
scripts/config-load
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
path="$(dirname "$(readlink -f "$0")")"
|
||||
backupDir="$HOME/.config/config-backup/$(date +%Y%m%d-%H%M%S)"
|
||||
backupDirCreated=0
|
||||
|
||||
sources=""
|
||||
if [ -z "$1" ]; then
|
||||
sources=$(find "$path/../config/" -maxdepth 1 -not -path "$path/../config")
|
||||
else
|
||||
for arg in "$@"; do
|
||||
src="$path/../config/$arg"
|
||||
if [ ! -e "$src" ]; then
|
||||
echo "Error: Config '$arg' does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
sources="$sources $path/../config/$arg"
|
||||
done
|
||||
fi
|
||||
|
||||
for src in $sources; do
|
||||
name="$(basename "$src")"
|
||||
dest="$HOME/.config/$name"
|
||||
|
||||
if [ -e "$dest" ] || [ -L "$dest" ]; then
|
||||
[ "$backupDirCreated" -eq 0 ] && {
|
||||
mkdir -pv "$backupDir"
|
||||
backupDirCreated=1
|
||||
}
|
||||
mv -vf "$dest" "$backupDir/"
|
||||
fi
|
||||
|
||||
ln -sv "$(realpath --relative-to="$HOME/.config" "$src")" "$dest"
|
||||
done
|
||||
Reference in New Issue
Block a user