-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinitialize.bash
More file actions
202 lines (185 loc) · 7.78 KB
/
initialize.bash
File metadata and controls
202 lines (185 loc) · 7.78 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env bash
set -e
here="$(dirname "$0")"
here="$(cd "$here"; pwd)"
(cd $here; git submodule init)
(cd $here; git submodule update)
mkln () {
for file in "$here"/"$1"*; do
name="$(basename "$file")"
if [[ !( " bin config initialize.bash oh-my-zsh-custom readme.md " =~ " $name " ) ]]; then
if [[ $2 == 't' ]]; then
if [[ -e "$HOME/.$1$name" ]]; then
rm -rv "$HOME/.$1$name"
fi
if [[ `uname` == 'Linux' ]]; then
ln -sfv $file "$HOME/.$1$name"
elif [[ `uname` == 'Darwin' ]]; then
ln -sfhv $file "$HOME/.$1$name"
else
echo "UNSUPPORTED PLATFORM!!!!!!!!!!"
exit 1
fi
else
if [[ -e "$HOME/.$1$name" ]]; then
echo " `dirname $HOME/.$1$name`/`basename\
$HOME/.$1$name`"
fi
fi
fi
done
}
chkln () {
for file in "$here/$1"*; do
name="$(basename "$file")"
if [[ -e "$HOME/$1$name" ]]; then
echo " `dirname $HOME/$1$name`/`basename\
$HOME/$1$name`"
fi
done
}
confirmYn () {
printf "$1"" (Y/n)"
read -n 1 a
while [[ ! $a == "Y" && ! $a == "n" ]]; do
printf "\nPlease answer (Y/n)"
read -n 1 a
done
echo ''
if [[ $a == "Y" ]]; then
$2
fi
}
printf "\033[1;31;49m=== Conflicting dotfiles in $HOME:\n\033[0m"
mkln '' f
mkln 'config/' f
chkln 'bin/'
stepInitDotfiles () {
if [[ ! -d "$HOME/.config" ]]; then
echo "Creating ~/.config"
mkdir "$HOME/.config"
fi
if [[ ! -d "$HOME/bin" ]]; then
echo "Creating ~/bin"
mkdir "$HOME/bin"
fi
mkln '' t
mkln 'config/' t
if [[ `uname` == 'Linux' ]]; then
find "$here/bin" -maxdepth 1 -mindepth 1 -type f -print0 | xargs -0 -L 1 -I % ln -sfv % "$HOME/bin/"
find "$here/oh-my-zsh-custom/custom" -maxdepth 1 -mindepth 1 -type f -print0 | xargs -0 -L 1 -I % ln -sfv % "$HOME/.oh-my-zsh/custom/"
find "$here/oh-my-zsh-custom/themes" -maxdepth 1 -mindepth 1 -print0 | xargs -0 -L 1 -I % ln -sfv % "$HOME/.oh-my-zsh/custom/themes/"
find "$here/oh-my-zsh-custom/custom/plugins/" -maxdepth 1 -mindepth 1 -print0 | xargs -0 -L 1 -I % ln -sfv % "$HOME/.oh-my-zsh/custom/plugins/"
find "$here/oh-my-zsh-custom/custom/ext/" -maxdepth 1 -mindepth 1 -print0 | xargs -0 -L 1 -I % ln -sfv % "$HOME/.oh-my-zsh/custom/"
elif [[ `uname` == 'Darwin' ]]; then
find "$here/bin" -type f -depth 1 -print0 | xargs -0 -L 1 -I % ln -sfhv % "$HOME/bin"
find "$here/oh-my-zsh-custom/custom" -type f -depth 1 -print0 | xargs -0 -L 1 -I % ln -sfhv % "$HOME/.oh-my-zsh/custom/"
find "$here/oh-my-zsh-custom/themes" -type f -depth 1 -print0 | xargs -0 -L 1 -I % ln -sfhv % "$HOME/.oh-my-zsh/custom/themes/"
find "$here/oh-my-zsh-custom/custom/plugins" -depth 1 -print0 | xargs -0 -L 1 -I % ln -sfhv % "$HOME/.oh-my-zsh/custom/plugins/"
find "$here/oh-my-zsh-custom/custom/ext" -depth 1 -print0 | xargs -0 -L 1 -I % ln -sfhv % "$HOME/.oh-my-zsh/custom/"
fi
}
confirmYn "\033[1;32;49m=== Overwrite those files?\033[0m" stepInitDotfiles
if [[ -e "$HOME/.vim" ]] && [[ ! -e "$HOME/.config/nvim" ]]; then
ln -sf $HOME/.vim $HOME/.config/nvim
fi
if [[ ! -d "$HOME/.vimbackup" ]]; then
echo "Creating ~/.vimbackup"
mkdir "$HOME/.vimbackup"
fi
if [[ ! -d "$HOME/.fonts" ]]; then
echo "Creating ~/.fonts"
mkdir "$HOME/.fonts"
fi
stepInstallStuff () {
if uname -a | grep -iq linux > /dev/null && grep -iq debian /etc/*release* > /dev/null; then
echo 'Installing stuff ...'
sudo apt update
sudo apt -y install aptitude python3 python3-dev git zsh curl wget python3-venv python3-pip
sudo apt -y install debhelper autotools-dev dh-autoreconf file libncurses5-dev libevent-dev pkg-config libutempter-dev build-essential
sudo apt -y install sqlite3 pipx
printf "\033[1;32;49m=== Type Y/y to install powerline: \033[0m"
read -n 1 c; echo ''; if [[ $c == 'Y' ]] || [[ $c == 'y' ]]; then
echo 'Installing powerline'
mkdir -p ~/.tmux/plugins/tpm
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
ln -sfv $here/tmux/tmux.conf $HOME/.tmux.conf
ln -sfv $here/tmux/tmux-powerline $HOME/.config/tmux-powerline
cp $here/tmux/tmux-powerline/config.sh.sample $here/tmux/tmux-powerline/config.sh
printf "\033[1;32;49m=== Type Y/y to install powerline patched fonts: \033[0m"
read -n 1 c; echo ''; if [[ $c == 'Y' ]] || [[ $c == 'y' ]]; then
sudo apt install -y fontconfig
if which fc-cache; then
echo 'Installing powerline-patched-font'
git clone https://github.com/Lokaltog/powerline-fonts $HOME/powerline-font-82374846
find $HOME/powerline-font-82374846 -regextype posix-extended -iregex '.*\.(otf|ttf)' -print0 | xargs -0 -I % mv -v % $HOME/.fonts/
rm -rfv $HOME/powerline-font-82374846
fc-cache -vf $HOME/.fonts/
fi
fi
fi
printf "\033[1;32;49m=== Type Y/y to change default shell to zsh: \033[0m"
read -n 1 c; echo ''; if [[ $c == 'Y' ]] || [[ $c == 'y' ]]; then
chsh -s `which zsh`
fi
printf "\033[1;32;49m=== Type Y/y to install neovim: \033[0m"
read -n 1 c; echo ''; if [[ $c == 'Y' ]] || [[ $c == 'y' ]]; then
sudo apt update
sudo apt -y install neovim
sudo apt -y install highlight tree
pipx install neovim
nvim +PlugInstall +qa
fi
elif uname -a | grep -iq linux > /dev/null && grep -iq manjaro /etc/*release* > /dev/null; then
echo 'Installing stuff...'
#pamac checkupdates || true
#pamac update --no-confirm
pamac install sqlite3 neovim tmux
nvim +PlugInstall +qa
elif uname -a | grep -iq darwin > /dev/null; then
if [ -f /usr/local/bin/brew ]; then
brew install python curl neovim wget python3 tmux zsh git reattach-to-user-namespace highlight tree
pipx install git+git://github.com/powerline/powerline
pipx install psutil
pipx install neovim
if grep -iq '/usr/local/bin/zsh' /etc/shells; then
printf " \033[1;34;49m /usr/local/bin/zsh is already in /etc/shells\033[0m\n"
else
printf " \033[1;34;49m Adding homebrew's zsh to /etc/shells\n\033[0m"
sudo sh -c 'echo "/usr/local/bin/zsh" >> /etc/shells'
fi
find /usr/local -iregex '.*tmux/powerline.conf' 2> /dev/null -print0 | xargs -0 -I % ln -sfv % $HOME/.powerline-tmux.conf
fi
fi
}
confirmYn "\033[1;32;49m=== Install zsh, python and powerline:\033[0m" stepInstallStuff
#echo $PWD
stepInstallFzf () {
if [[ ! -d "$HOME/.fzf" ]]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
else
(cd ~/.fzf; git pull origin master)
fi
~/.fzf/install --all --no-update-rc
}
confirmYn "\033[1;32;49m=== Install/update fzf:\033[0m" stepInstallFzf
stepConfigGitName () {
while [[ x${git_global_name} == 'x' ]]; do
read -rp "gitconfig global name: " git_global_name
done
while [[ x${git_global_email} == 'x' ]]; do
read -rp "gitconfig global email: " git_global_email
done
cat <<EOF > $HOME/.gitconfigp
[user]
name = ${git_global_name}
email = ${git_global_email}
[core]
excludesfile = $HOME/.gitignore
EOF
}
if [ -f $HOME/.gitconfigp ]; then
confirmYn "\033[1;32;49m=== Config local git name/email:\033[0m" stepConfigGitName
else
stepConfigGitName
fi