-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakesymlinks.sh
executable file
·26 lines (23 loc) · 999 Bytes
/
makesymlinks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
#
# Create symlinks from the home directory to all dotfiles
# in the same directory as this script resides.
# The repository can be saved in whichever path the user wants.
#
# 'mv' does not follow symlinks. That means that if the script is run
# multiple times, the files will only get copied the first time, as
# long as the files wasn't symlinked in the first place.
readonly SOURCE_DIR="$(dirname "$(realpath "$0")")" # Absolute path to script.
readonly BACKUP_DIR="${SOURCE_DIR}/dotfiles_old"
declare -ar FILES=(bashrc vimrc lintianrc gbp.conf sbuildrc inputrc)
echo "Creating ${BACKUP_DIR} for backup of any existing dotfiles in ${HOME}"
mkdir -p "${BACKUP_DIR}"
echo "...done"
echo "Move existing dotfiles from ${HOME} to ${BACKUP_DIR}"
for file in "${FILES[@]}"; do
if [[ -f "${HOME}/.${file}" ]]; then
mv "${HOME}/.${file}" "${BACKUP_DIR}"
fi
echo "Creating symlink to ${file} in home directory."
ln -sf "${SOURCE_DIR}/${file}" "${HOME}/.${file}"
done