-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot.sh
executable file
·169 lines (139 loc) · 4.05 KB
/
dot.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
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
#!/usr/bin/env zsh
DIR="$(dirname "$(readlink -f "$0")")"
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
# golang
mkdir -p ~/go
# gpg
mkdir -p -m 700 ~/.gnupg
# rust
mkdir -p ~/.cargo/bin
# ssh
mkdir -p ~/.ssh
# vim
mkdir -p ~/.vim/bundle # Create directory for Vundle
}
_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
# 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"
brew bundle --no-lock --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 vundle if missing
if [ ! -d ~/.vim/bundle/Vundle.vim ]; then
echo "\n$(tput bold)Installing Vundle $(tput sgr0) ...\n"
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
fi
echo "\n$(tput bold)Updating Vundle $(tput sgr0)...\n"
/bin/zsh -c "cd ~/.vim/bundle/Vundle.vim; git pull origin master"
echo "\n$(tput bold)Updating Vim plugins $(tput sgr0)...\n"
# Supress attaching to tty
echo | echo | vim +PluginInstall! +PluginClean! +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