-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·53 lines (42 loc) · 1.47 KB
/
setup.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# ~/dotfiles/setup.sh
# This script creates symlinks from dotfiles dir to their respective locations
set -euo pipefail
IFS=$'\n\t'
REPO_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
echo -e "\x1B[32m* Starting $REPO_DIR install at: $(date +%s) *\x1B[0m"
# Terminal config
files=( "shell/.bashrc" "shell/.zshenv" "shell/.zshrc" "shell/.inputrc" "shell/.editrc" "tools/.prettierrc" "tools/.tmux.conf" "tools/.vimrc" "git/.gitconfig" )
echo "Moving existing dotfiles from ~ to $oldDir"
for file in "${files[@]}"; do
filename=$(basename $file)
filedir=$(dirname $file)
if [[ -f ~/$filename && ! -L ~/$filename ]]; then
# Backup old dotfile if not a symlink
mv ~/$filename ~/$filename.$(date +%s).bak
fi
echo "Creating symlink to $filename"
ln -svf $REPO_DIR/$file ~/$filename
done
# VSCode config
vsFiles=( "settings.json" "keybindings.json" )
if [[ "$OSTYPE" == "darwin"* ]]; then
vsPath=~/Library/Application\ Support/Code/User
else
vsPath=~/.config/Code/User
fi
echo "Setting up VSCode configs in $vsPath"
mkdir -p $vsPath
for file in "${vsFiles[@]}"; do
if [[ -f $vsPath/$file && ! -L $vsPath/$file ]]; then
# Backup old config if not a symlink
mv $vsPath/$file $vsPath/$file.$(date +%s).bak
fi
echo "Creating symlink to $file"
ln -svf $REPO_DIR/vscode/$file $vsPath/$file
done
# restore $IFS
IFS=$SAVEIFS
echo -e "\x1B[32m* Completed dotfiles setup at $(date +%s) *\x1B[0m"