Created
October 19, 2023 01:47
-
-
Save joshmenden/25fc4498875198faf9e4ee4019c1ae81 to your computer and use it in GitHub Desktop.
A bash script for setting up the symlinks for your dot files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
green='\033[0;32m' | |
reset='\033[0m' | |
# position-based matching | |
# pwd assumes you are running this from the root of your dotfile dir | |
files=( ~/.zshrc ) | |
links=( "$(pwd)/.zshrc" ) | |
for index in ${!files[*]}; do | |
file=${files[$index]} | |
link=${links[$index]} | |
if [ -e $file ]; then | |
read -p "Are you sure you want to delete $file? (y/n) " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
echo "Deleting $file" | |
rm -rf "$file" | |
echo "Creating symbolic link: $file -> $link" | |
ln -s "$link" "$file" | |
echo "Link created successfully." | |
else | |
echo "No changes made." | |
fi | |
else | |
echo "$file does not exist. Creating symbolic link: $file -> $link" | |
ln -s "$link" "$file" | |
echo "Link created successfully." | |
fi | |
echo | |
done | |
echo -e "${green}dotfiles generated!${reset}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment