-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-everything
executable file
·145 lines (137 loc) · 3.91 KB
/
setup-everything
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
source _helpers.sh
if prompt "Symlink dotfiles?"; then
./dotphile
fi
if grep --quiet github.com < ~/.ssh/config; then
echo -e " ${GREEN}✓${NORMAL} github key present"
elif prompt " ${RED}✗${NORMAL} missing github key - create?"; then
set -eoux pipefail
ssh-keygen -t ed25519 -C "[email protected]" -f "$HOME/.ssh/github"
pbcopy < ~/.ssh/github.pub
eval "$(ssh-agent -s)"
(
set +x
echo
echo Key has been copied to clipboard. Add this key to github
read -p "(press enter) " -n 1 -r || exit 1; echo
)
open https://github.com/settings/keys
touch ~/.ssh/config
tee -a ~/.ssh/config <<END
Host github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/github
END
fi
if [[ -f './hammerspoon/Spoons/hs_select_window.spoon/.git' ]]; then
echo -e " ${GREEN}✓${NORMAL} git submodule present"
elif prompt " ${RED}✗${NORMAL} missing git submodule - clone?"; then
(
set -ex
git submodule update --recursive --remote
)
fi
if [[ $(command -v fzf) ]]; then
echo -e " ${GREEN}✓${NORMAL} fzf installed"
elif prompt " ${RED}✗${NORMAL} missing fzf - install?"; then
[[ -d "$HOME/.fzf" ]] && echo_and_run rm -rf "$HOME/.fzf"
echo_and_run git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
echo_and_run ~/.fzf/install --all
fi
function install_cmd() {
local dnf=''
local brew=''
local apt=''
local linux=''
local not=''
local cmd="$1"; shift;
while :; do
case $1 in
--dnf)
if [[ "$2" ]]; then
dnf="$2"
shift
else
echo "missing dnf value"
exit 1
fi
;;
--not=?*)
not="${1#*=}"; shift;
;;
--linux=?*)
linux="${1#*=}"; shift;
;;
--brew=?*)
brew="${1#*=}"; shift;
;;
--dnf=?*)
dnf="${1#*=}"; shift;
;;
--apt=?*)
apt="${1#*=}"; shift;
;;
?*)
echo "unknown option \"$1\""
exit 1
;;
*)
break;
esac
done
if [[ $(command -v "$cmd") && "$(command -v "$cmd")" != "$not" ]]; then
echo -e " ${GREEN}✓${NORMAL} $cmd installed"
elif prompt " ${RED}✗${NORMAL} missing $cmd - install?"; then
if [[ -n "$linux" && "$(uname -s)" == "Linux" ]]; then
eval "echo_and_run $linux"
elif [[ $(command -v brew) ]]; then
if [[ -n "$brew" ]]; then
eval "echo_and_run $brew"
else
echo_and_run brew install "$cmd"
fi
elif [[ $(command -v dnf) ]]; then
if [[ -n "$dnf" ]]; then
eval "echo_and_run $dnf"
else
echo_and_run sudo dnf install --assumeyes "$cmd"
fi
elif [[ $(command -v apt) ]]; then
if [[ -n "$apt" ]]; then
eval "echo_and_run $apt"
else
echo_and_run sudo apt install "$cmd"
fi
else
echo "I don't know how to install this"
exit 1
fi
fi
}
function install_git_number_on_linux() {
echo_and_run mkdir -p ~/git/git-number
echo_and_run git clone https://github.com/holygeek/git-number.git ~/git/git-number
(
cd ~/git/git-number || exit 1;
echo_and_run sudo make install;
);
}
install_cmd zsh --not="/bin/zsh"
install_cmd rg --brew="brew install ripgrep" --dnf="sudo dnf install --assumeyes ripgrep"
install_cmd git-number --linux="install_git_number_on_linux"
install_cmd alacritty
install_cmd bat
install_cmd delta --brew="brew install git-delta" --dnf="sudo dnf install --assumeyes git-delta"
install_cmd lsd
install_cmd node
install_cmd kitty --brew="curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin" --dnf="curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin" --apt="curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin"
install_cmd direnv
install_cmd zoxide
# install_cmd fish
# install_cmd shellcheck --dnf="sudo dnf install --assumeyes ShellCheck"
# install_cmd tmux
# install_cmd vint # vimscript linting
zsh/setup-zsh.sh
osx/set-defaults.sh