-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_dotfiles.sh
executable file
·53 lines (47 loc) · 2.11 KB
/
setup_dotfiles.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
#!/usr/bin/env bash
# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DIR=$(exec 2>/dev/null;cd -- $(dirname "$0"); unset PWD; /usr/bin/pwd || /bin/pwd || pwd)
for dotfile in ".gitconfig" ".git-credential-helper.sh" ".inputrc" ".nanorc" ".profile.d" ".pylintrc" ".ssh" ".jupyter"; do
# if it doesn't exist, or exists but is a symlink...
if ! [ -e "$HOME/$dotfile" ] || [ -h "$HOME/$dotfile" ]; then
rm -f "$HOME/$dotfile"
ln -vs "$DIR/$dotfile" "$HOME/$dotfile"
else
echo "Already present: $HOME/$dotfile"
fi
done
mkdir -p ~/.ipython/profile_default/startup/
ln -vs "$DIR/.ipython/profile_default/startup/00-init.ipy" ~/.ipython/profile_default/startup/00-init.ipy
if ! grep -Fq ".profile.d" ~/.profile; then
echo "Appending source lines to .profile"
echo "for fn in ~/.profile.d/*.sh; do source "\$fn"; done" >> ~/.profile
touch ~/.profile.d/per-host/$(hostname -s).sh
echo "source ~/.profile.d/per-host/$(hostname -s).sh" >> ~/.profile
else
echo "~/.profile.d is already mentioned in .profile, not adding source lines"
fi
# Why does this have to be named .zshrc to get colors to work? :(
if ! grep -Fq ".profile.d" ~/.zshrc; then
echo "Appending source lines to .zshrc"
echo "for fn in ~/.profile.d/*.zsh; do source "\$fn"; done" >> ~/.zshrc
touch ~/.profile.d/per-host/$(hostname -s).zsh
echo "source ~/.profile.d/per-host/$(hostname -s).zsh" >> ~/.zshrc
else
echo "~/.profile.d is already mentioned in .zshrc, not adding source lines"
fi
# Special case for platform-dependent VSCode config file
if [[ $OSTYPE == darwin* ]]; then
destpath="$HOME/Library/Application Support/Code/User/settings.json"
else
destpath="$HOME/.config/Code/User/settings.json"
fi
if ! [[ -e "$destpath" ]]; then
mkdir -p "$(dirname "$destpath")"
cp "$DIR/vscode-settings.json" "$destpath"
fi
if [[ $platform == "Linux" && $XDG_SESSION_TYPE == x11 ]]; then
mkdir -p ~/.local/share/applications/
rsync -av $DIR/.local/share/applications/ ~/.local/share/applications/
mkdir -p ~/.config/autostart/
rsync -av $DIR/.config/autostart/ ~/.config/autostart/
fi