-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·105 lines (83 loc) · 3.35 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash -eu
export ESC=$(printf '\033')
export RESET="${ESC}[0m"
export GREEN="${ESC}[32m"
export CYAN="${ESC}[36m"
export PS4='${CYAN}+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME:+$FUNCNAME(): }${RESET}'
export __STEP__="echo -e \n${GREEN}#"
trap "echo SIGINT; exit 1" SIGINT
os=$(uname)
sudoer_mode=false
read -n1 -p "Sudoer mode? (y/N)" yn; echo
[[ $yn = [yY] ]] && sudo -v >/dev/null 2>&1 && sudoer_mode=true
read -p "Press enter to continue (OS: $os, Sudoer mode: $sudoer_mode)"
root=$(git rev-parse --show-toplevel)
cd $root
backup_dir=$root/.backup/$(date -Iseconds)
mkdir -p $backup_dir
echo "*" > $backup_dir/.gitignore
function symlink() {
sudo_prefix=""
[[ $2 == $HOME/* ]] || sudo_prefix="sudo"
[[ -e $2 ]] && $sudo_prefix mv $2 $backup_dir
$sudo_prefix ln -sfn $1 $2
}
set -x
$__STEP__ "Create symlinks"
# enable to create synlinks in Git Bash
[[ "$os" = MINGW* ]] && export MSYS=winsymlinks:nativestrict
symlink $root/common/.bash_profile ~/.bash_profile
symlink $root/common/.bashrc ~/.bashrc
symlink $root/common/.gitconfig ~/.gitconfig
symlink $root/common/.gittemplate.txt ~/.gittemplate.txt
mkdir -p ~/.config
symlink $root/common/gitmoji-nodejs ~/.config/gitmoji-nodejs
symlink $root/common/fish ~/.config/fish
symlink $root/common/mise ~/.config/mise
symlink $root/common/starship.toml ~/.config/starship.toml
symlink $root/common/zellij ~/.config/zellij
$__STEP__ "Setup for $os"
case "$os" in
Linux)
symlink $root/common/helix ~/.config/helix
if [[ "$(uname -r)" == *-microsoft-standard-WSL2 ]]; then
symlink $root/common/vscode/settings.json ~/.vscode-server/data/Machine/settings.json
$sudoer_mode && symlink $root/wsl/wsl.conf /etc/wsl.conf
fi
if command -v apt >/dev/null 2>&1; then
$sudoer_mode && ./setup/apt.sh
./setup/rustup.sh
./setup/font.sh
else
echo "Unsupported Linux distribution"
exit 1
fi
;;
Darwin)
symlink $root/common/helix ~/.config/helix
symlink $root/mac/.Brewfile ~/.Brewfile
symlink $root/mac/.Brewfile.lock.json ~/.Brewfile.lock.json
symlink $root/mac/.gitconfig.mac ~/.gitconfig.mac
symlink $root/mac/skhd ~/.config/skhd
symlink $root/mac/yabai ~/.config/yabai
symlink $root/mac/warp ~/.warp
$sudoer_mode && ./setup/brew.sh
./setup/rustup.sh
./setup/font.sh
;;
MINGW*)
symlink $root/win/.wslconfig ~/.wslconfig
symlink $root/win/terminal/settings.json ~/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json
symlink $root/win/vscode/settings.json ~/AppData/Roaming/Code/User/settings.json
symlink $root/common/helix ~/AppData/Roaming/helix
symlink $root/win/Microsoft.PowerShell_profile.ps1 ~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1
symlink $root/win/Microsoft.PowerShell_profile.ps1 ~/Documents/PowerShell/Microsoft.VSCode_profile.ps1
./setup/winget.sh
./setup/rustup.sh
./setup/font.sh
;;
*)
echo "Unsupported OS"
exit 1
;;
esac