renamed all files such that they match they target destination

This commit is contained in:
Carlos Sousa 2025-07-11 14:30:53 +02:00
parent 59991e5b7d
commit e2d6eb034f
62 changed files with 0 additions and 69 deletions

View File

@ -1,42 +0,0 @@
#!/bin/bash
# Load the pairs from the JSON file
pairs=$(jq -r '.[] | "\(.source)=\(.destination)=\(.type)"' deployment_playbook.json)
# Loop through the pairs and copy the source to the destination
for pair in ${pairs[@]}; do
# Split the pair into source and destination
IFS='=' read -ra pair_array <<< "$pair"
source=$(echo "${pair_array[0]}" | sed 's/\\"/"/g')
destination=$(echo "${pair_array[1]}" | sed 's/\\"/"/g')
type=$(echo "${pair_array[2]}" | sed 's/\\"/"/g')
# Expand ~ if used in the destination
destination="${destination/#\~/$HOME}"
# Check if the destination already exists
if [ -e "$destination" ]; then
# Backup the destination based on the type
if [ "$type" == "append" ]; then
echo "Backing up $destination to $destination.backup (cp -r)"
cp -r "$destination" "$destination.backup"
elif [ "$type" == "replace" ]; then
echo "Backing up $destination to $destination.backup (mv)"
mv "$destination" "$destination.backup"
else
echo "Invalid type: $type"
continue
fi
fi
# Create the directory up to the destination path if it doesn't exist
destination_dir=$(dirname "$destination")
if [ ! -d "$destination_dir" ]; then
echo "Creating directory: $destination_dir"
mkdir -p "$destination_dir"
fi
# Copy the source to the destination
echo "Copying $source to $destination"
cp -r "$source" "$destination"
done

View File

@ -1,27 +0,0 @@
[
{
"source": "config/nvim",
"destination": "~/.config/nvim",
"type": "replace"
},
{
"source": "oh-my-zsh/custom",
"destination": "~/.oh-my-zsh/custom",
"type": "replace"
},
{
"source": "home/tmux.conf",
"destination": "~/.tmux.conf",
"type": "replace"
},
{
"source": "home/gitconfig",
"destination": "~/.gitconfig",
"type": "replace"
},
{
"source": "local/scripts",
"destination" : "~/.local/scripts",
"type": "replace"
}
]