-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·69 lines (54 loc) · 2.29 KB
/
install.sh
File metadata and controls
executable file
·69 lines (54 loc) · 2.29 KB
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
#!/usr/bin/env bash
set -e
DOTFILES_ROOT=$(pwd -P)
echo -e "Dotfiles dir: $DOTFILES_ROOT"
OMZ_DIR=$HOME/.oh-my-zsh
echo -e "Oh-My-ZSH path: $OMZ_DIR"
[ ! -d "$OMZ_DIR" ] && sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
ZSH_CUSTOM=${ZSH_CUSTOM:-$OMZ_DIR/custom}
echo -e "ZSH_CUSTOM path: $ZSH_CUSTOM"
ZSH_THEMES=${ZSH_CUSTOM}/themes
ZSH_PLUGINS=${ZSH_CUSTOM}/plugins
[ ! -d "$ZSH_THEMES/powerlevel9k" ] && git clone https://github.com/Powerlevel9k/powerlevel9k.git ${ZSH_THEMES}/powerlevel9k
# installs zsh-syntax-highlighting plugin to a common directory
[ ! -d "$ZSH_PLUGINS/zsh-syntax-highlighting" ] && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_PLUGINS}/zsh-syntax-highlighting
[ ! -d "$ZSH_PLUGINS/zsh-nvm" ] && git clone https://github.com/lukechilds/zsh-nvm.git ${ZSH_PLUGINS}/zsh-nvm
# Files where tools may append to ~/<file> (e.g. `gt completion >> ~/.zshrc`,
# `git config --global …`, pnpm/nvm/conda installers). Install as a real file
# that sources/includes the tracked one, so tool-injected lines stay local
# in ~/.zshrc.local / ~/.gitconfig.local and never get committed.
install_zshrc_stub() {
if [ -L ~/.zshrc ] || [ ! -f ~/.zshrc ]; then
rm -f ~/.zshrc
cat > ~/.zshrc <<EOF
# Tracked dotfiles
[ -f "${DOTFILES_ROOT}/zshrc" ] && source "${DOTFILES_ROOT}/zshrc"
# Local additions live below — never committed.
# Tools that append to ~/.zshrc (gt completion, nvm, pnpm, tec, etc.) land here.
[ -f "\$HOME/.zshrc.local" ] && source "\$HOME/.zshrc.local"
EOF
echo "Created ~/.zshrc stub"
else
echo "Skipped ~/.zshrc (already a real file; not overwriting)"
fi
}
install_gitconfig_stub() {
if [ -L ~/.gitconfig ] || [ ! -f ~/.gitconfig ]; then
rm -f ~/.gitconfig
cat > ~/.gitconfig <<EOF
[include]
path = ${DOTFILES_ROOT}/gitconfig
path = ~/.gitconfig.local
EOF
echo "Created ~/.gitconfig stub"
else
echo "Skipped ~/.gitconfig (already a real file; not overwriting)"
fi
}
install_zshrc_stub
install_gitconfig_stub
# Global gitignore — git reads this via `core.excludesfile = ~/.gitignore`.
ln -sf ${DOTFILES_ROOT}/gitignore ~/.gitignore
# Note: aliases and macos_aliases are sourced directly from the repo by zshrc,
# so they don't need symlinks in $HOME.
echo -e "Dotfiles installed succesfully!"