Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
# dotfiles directory
dotfiledir="${HOME}/dotfiles"

# Create the backup directory if it doesn't exist
currentdate=$(date +%Y-%m-%d)
backupdir="${HOME}/dotfiles/backups/${currentdate}"

mkdir -p "${backupdir}"
echo "Backup dir created"

# list of files/folders to symlink in ${homedir}
files=(zshrc zprofile zprompt bashrc bash_profile bash_prompt aliases private)

Expand All @@ -19,6 +26,12 @@ cd "${dotfiledir}" || exit

# create symlinks (will overwrite old dotfiles)
for file in "${files[@]}"; do
if [ -e "${HOME}/.${file}" ]; then
# Backup existing files to the backup directory
echo "Backing up $file to ${backupdir}"
cp "${HOME}/.${file}" "${backupdir}/"
fi

echo "Creating symlink to $file in home directory."
ln -sf "${dotfiledir}/.${file}" "${HOME}/.${file}"
done
Expand Down