-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·71 lines (51 loc) · 2.11 KB
/
install.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
set -euo pipefail
# Ask for the administrator password upfront
sudo -v
# Get current dir (so run this script from anywhere)
export DOTFILES_DIR DOTFILES_CACHE DOTFILES_EXTRA_DIR
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DOTFILES_CACHE="$DOTFILES_DIR/.cache.fish"
DOTFILES_EXTRA_DIR="$HOME/.dotfiles_extra"
rm -f "$DOTFILES_CACHE"
# Make utilities available
PATH="$DOTFILES_DIR/bin:$PATH"
# Backup
STAMP=$(date +"%Y-%m-%d_%H-%M-%S")
BACKUP_DEST="$DOTFILES_DIR/backup/$STAMP/"
mkdir -p "$BACKUP_DEST"
[ -f "$HOME/.gitconfig" ] && cp "$HOME/.gitconfig" "$BACKUP_DEST"
[ -f "$HOME/.config/htop/htoprc" ] && cp "$HOME/.config/htop/htoprc" "$BACKUP_DEST"
[ -f "$HOME/.config/fish/config.fish" ] && cp "$HOME/.config/fish/config.fish" "$BACKUP_DEST"
[ -f "$HOME/.screenrc" ] && cp "$HOME/.screenrc" "$BACKUP_DEST"
[ -f "$HOME/Library/Application Support/Code/User/settings.json" ] && cp "$HOME/Library/Application Support/Code/User/settings.json" "$BACKUP_DEST"
[ -f "$HOME/.config/Code/User/settings.json" ] && cp "$HOME/.config/Code/User/settings.json" "$BACKUP_DEST"
# Bunch of symlinks
ln -sfv "$DOTFILES_DIR/configs/.gitconfig" "$HOME"
ln -sfv "$DOTFILES_DIR/configs/.gitignore_global" "$HOME/.gitignore"
mkdir -p "$HOME/.config/fish"
ln -sfv "$DOTFILES_DIR/configs/config.fish" "$HOME/.config/fish"
mkdir -p "$HOME/.config/htop"
ln -sfv "$DOTFILES_DIR/configs/htoprc" "$HOME/.config/htop"
if is-macos; then
mkdir -p "$HOME/Library/Application Support/iTerm2/DynamicProfiles/"
ln -sfv "$DOTFILES_DIR/configs/iterm-profiles.json" "$HOME/Library/Application Support/iTerm2/DynamicProfiles/"
fi
ln -sfv "$DOTFILES_DIR/configs/.screenrc" "$HOME"
for file in "$DOTFILES_DIR"/install/*; do
. $file
done
# Install extra stuff
if [ -d "$DOTFILES_EXTRA_DIR" ] && [ -f "$DOTFILES_EXTRA_DIR/install.sh" ]; then
echo "applying $DOTFILES_EXTRA_DIR/install.sh"
. "$DOTFILES_EXTRA_DIR/install.sh"
fi
if is-macos; then
# No brew or other automatic method available
echo
echo "Install Fork from https://git-fork.com/"
echo
fi
echo
echo "Some changes may require a restart to take effect."
echo