-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot.sh
More file actions
executable file
·177 lines (146 loc) · 4.24 KB
/
dot.sh
File metadata and controls
executable file
·177 lines (146 loc) · 4.24 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/env zsh
DIR="${0:A:h}"
getpath=$(git config --global get.path || echo "")
if [ -z "$getpath" ]; then
getpath="${GETPATH:-~/src}"
fi
_usage() {
echo "Usage: ./dot.sh [COMMAND]
Commands:
help prints this dialog
clone clones dotfiles to GETPATH (${getpath})
link symlinks dotfiles
install installs all packages
install-defaults installs macos defaults
install-brew installs homebrew packages
install-fisher installs fisher packages
install-vim installs vim packages
"
}
_pre() {
. "$DIR/sh/.shrc"
# fish
mkdir -p ~/.config/fish/functions # Create directory for fish-shell
touch ~/.config/fish/private.fish # Create private env vars file
# git
mkdir -p ~/.config/git
# ghostty
mkdir -p ~/.config/ghostty
# golang
mkdir -p ~/go
# gpg
mkdir -p -m 700 ~/.gnupg
# rust
mkdir -p ~/.cargo/bin
# ssh
mkdir -p ~/.ssh
# vim
mkdir -p ~/.vim
}
_clone() {
echo "\n$(tput bold)Cloning dotfiles to $getpath/github.com/arbourd/dotfiles $(tput sgr0)...\n"
mkdir -p "$getpath/github.com/arbourd"
git clone https://github.com/arbourd/dotfiles.git "$getpath/github.com/arbourd/dotfiles"
echo "\n$(tput bold)$getpath/github.com/arbourd/dotfiles$(tput sgr0)"
}
_link() {
echo "\n$(tput bold)Symlinking dotfiles $(tput sgr0)...\n"
# bash, fish and zsh
ln -vsf "$DIR/sh/.shrc" ~/.bash_profile
ln -vsf "$DIR/sh/.shrc" ~/.zshrc
ln -vsf "$DIR/sh/config.fish" ~/.config/fish/config.fish
ln -vsf "$DIR/sh/fish_plugins" ~/.config/fish/fish_plugins
# ghostty
ln -vsf "$DIR/ghostty/config" ~/.config/ghostty/config
# git
ln -vsf "$DIR/git/config" ~/.config/git/config
ln -vsf "$DIR/git/gitignore" ~/.config/git/gitignore
# gpg
ln -vsf "$DIR/gpg/gpg-agent.conf" ~/.gnupg/gpg-agent.conf
# ssh
ln -vsf "$DIR/ssh/config" ~/.ssh/config
# vim
ln -vsf "$DIR/vim/vimrc" ~/.vim/vimrc
}
_install_defaults() {
echo "\n$(tput bold)Setting macOS defaults $(tput sgr0)...\n"
$DIR/.macOS
}
_install_brew() {
# Install Homebrew if missing
if ! command -v brew &> /dev/null ; then
echo "\n$(tput bold)Installing Homebrew $(tput sgr0)...\n"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
echo "\n$(tput bold)Installing Homebrew packages $(tput sgr0)...\n"
HOMEBREW_BUNDLE_NO_LOCK=1 brew bundle --file "$DIR/Brewfile"
}
_install_fisher() {
# Install fish if missing
if ! command -v fish &> /dev/null ; then
echo "\n$(tput bold)Installing fish $(tput sgr0)...\n"
brew install fish
fi
echo "\n$(tput bold)Updating and installing fisher plugins $(tput sgr0)...\n"
fish -c "curl -fsSL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher"
fish -c "git checkout $DIR/sh/fish_plugins"
fish -c "fisher update"
}
_install_vim() {
# Install vim-plug if missing
if [ ! -f ~/.vim/autoload/plug.vim ]; then
echo "\n$(tput bold)Installing vim-plug $(tput sgr0) ...\n"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
else
echo "\n$(tput bold)Updating vim-plug $(tput sgr0)...\n"
curl -fLo ~/.vim/autoload/plug.vim \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
echo "\n$(tput bold)Updating Vim plugins $(tput sgr0)...\n"
# Supress attaching to tty
echo | echo | vim +PlugUpdate +PlugClean! +qall &>/dev/null
}
_install() {
_install_brew
_install_defaults
_install_fisher
_install_vim
}
case $1 in
clone)
_clone
;;
link)
_pre
_link
;;
install)
_pre
_install
;;
install-brew)
_pre
_install_brew
;;
install-defaults)
_pre
_install_defaults
;;
install-fisher)
_pre
_install_fisher
;;
install-vim)
_pre
_install_vim
;;
help)
_usage
exit 0
;;
*)
_usage
exit 0
;;
esac