-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_onchange_install-package.sh.tmpl
131 lines (119 loc) · 3.64 KB
/
run_onchange_install-package.sh.tmpl
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
set -euox pipefail
IFS="$(printf " \t\nx")"
# XDG Base Directory Specification
XDG_CONFIG_HOME="${HOME}/.config"
# data direcotory for zsh
ZDOTDIR="${XDG_CONFIG_HOME}/zsh"
# misc
ZSH_FUNCCOMP_DIR="${ZDOTDIR}/func_comp"
CURRENT_DIR="~/.share/chezmoi"
command mkdir -p "${ZSH_FUNCCOMP_DIR}"
command_exists() {
command -v "$1" >/dev/null 2>&1
}
{{ if eq .chezmoi.os "darwin" -}}
: "macOS" && {
: "GUI" && {
defaults write com.apple.Dock orientation -string left
defaults write -g ApplePressAndHoldEnabled -bool false
defaults write -g ApplePressAndHoldEnabled -bool false
}
: "password" && {
sudo bash -c "cat <<EOF > /etc/pam.d/sudo
# sudo: auth account password session
auth sufficient pam_smartcard.so
auth sufficient pam_tid.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
EOF"
}
: "brew" && {
# Doc: https://brew.sh/
if ! command_exists "brew"; then
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
export PATH="${PATH}:/opt/homebrew/bin"
# Doc: https://homebrew-file.readthedocs.io/en/latest/usage.html
brew bundle install --file ".Brewfile" --no-lock
fi
}
: "nix" && {
if ! command_exists "nix"; then
sh <(curl -L https://nixos.org/nix/install) --daemon
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
nix-channel --update
fi
}
}
{{ else if eq .chezmoi.osRelease.id "linux-debian" -}}
: "apt" && {
# https://askubuntu.com/questions/462094/unable-to-install-libssl1-0-0i386-due-to-unmet-dependencies/462471#462471
sudo apt update
sudo apt upgrade -y
sudo apt purge -y --autoremove
sudo apt install -y build-essential neovim wget curl direnv zsh git
}
: "remap keys" && {
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']" # turn capslock into control
}
: "fzf" && {
if ! command_exists "fzf"; then
# Doc: https://github.com/junegunn/fzf#installation
if [ -d "~/.fzf" ]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
fi
~/.fzf/install
fi
}
}
{{ end -}}
: "misc" && {
: "starship" && {
if ! command_exists starship; then
# https://github.com/starship/starship#step-1-install-starship
curl -sS https://starship.rs/install.sh | sh -s -- --yes
fi
}
: "zplug" && {
if ! [ -d "${HOME}/.zplug" ]; then
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
fi
}
}
: "laguages" && {
: "rust" && {
if ! command_exists rustup; then
# Doc: https://www.rust-lang.org/tools/install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
# shellcheck disable=SC1091
source "${HOME}/.cargo/env"
fi
if command_exists rustup; then
rustup toolchain install stable
rustup toolchain install nightly
rustup update
# Doc: https://rust-lang.github.io/rustup/installation/index.html#enable-tab-completion-for-bash-fish-zsh-or-powershell
rustup completions zsh >"${ZSH_FUNCCOMP_DIR}/_rustup"
fi
if command_exists cargo; then
cargo install \
bat \
bottom \
exa \
fd-find \
git-delta \
hyperfine \
ripgrep \
tokei
fi
}
}
: "update_font" && {
fc-cache -fv
}
: "change shell" && {
[ "$SHELL" != "$(which zsh)" ] && chsh -s "$(which zsh)" && exec zsh -l
}
echo "Complete installation!"