-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·93 lines (77 loc) · 2.5 KB
/
deploy.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
#!/bin/sh
set -euf
CURDIR=$( cd "$(dirname "$0")" ; pwd -P )
if ! grep -q -s "path = $CURDIR/gitconfig" ~/.gitconfig; then
cat >> ~/.gitconfig <<EOT
[include]
path = $CURDIR/gitconfig
EOT
echo "Infected .gitconfig"
fi
include_in_file() {
local filename="$1"
local string="$2"
if ! grep -q -s "$string" "$filename"; then
mkdir -p ~/.vim/backup
if [ ! -e "$filename" ]; then
touch "$filename"
fi
echo "$string" > "$filename.tmp"
cat "$filename" >> "$filename.tmp"
mv "$filename.tmp" "$filename"
echo "Infected $filename"
fi
}
mkdir -p ~/.vim/backup
include_in_file ~/.vimrc "source $CURDIR/vimrc"
include_in_file ~/.tmux.conf "source $CURDIR/tmux.conf"
ZSH_PATH=$(command -v zsh)
if [ $ZSH_PATH ]; then
echo "$ZSH_PATH found, configuring"
if [ ! -e ~/.oh-my-zsh ]; then
echo "Installing oh-my-zsh"
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
fi
ZSH_PLUGINDIR=~/.oh-my-zsh/custom/plugins
ZSH_PLUGINS="zsh-autosuggestions zsh-syntax-highlighting"
for plugin in $ZSH_PLUGINS; do
if [ ! -e $ZSH_PLUGINDIR/$plugin ]; then
echo "Installing $plugin"
git clone https://github.com/zsh-users/$plugin.git $ZSH_PLUGINDIR/$plugin
fi
done
if [ ! -e ~/.oh-my-zsh/custom/themes/maarten.zsh-theme ]; then
ln -s $CURDIR/maarten.zsh-theme ~/.oh-my-zsh/custom/themes/maarten.zsh-theme
fi
if [ ! -e ~/.oh-my-zsh/custom/fix_slow_paste.zsh ]; then
ln -s $CURDIR/fix_slow_paste.zsh ~/.oh-my-zsh/custom/fix_slow_paste.zsh
fi
if [ ! -e ~/.zshrc ]; then
cat > ~/.zshrc << EOF
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="maarten"
plugins=(git $ZSH_PLUGINS)
source \$ZSH/oh-my-zsh.sh
export LANG=en_US.UTF-8
# Put custom aliases and stuff in \$ZSH_CUSTOM!
EOF
echo "Deployed .zshrc"
fi
if ! grep -q -s DEFAULT_USER ~/.zshenv; then
echo "DEFAULT_USER=$USER" >> ~/.zshenv
fi
if [ $SHELL != $ZSH_PATH ]; then
echo "Configuring zsh as current shell"
chsh -s $ZSH_PATH
fi
fi
if [ ! $ZSH_PATH ]; then
if ! grep -q dotfiles/.bashrc ~/.bashrc >/dev/null 2>&1; then
echo "if [ -f ~/dotfiles/.bashrc ]; then . ~/dotfiles/.bashrc; fi" >> ~/.bashrc
echo "Infected .bashrc"
fi
if ! grep -q .bashrc.local ~/.bashrc >/dev/null 2>&1; then
echo "if [ -f ~/.bashrc.local ]; then . ~/.bashrc.local; fi" >> ~/.bashrc
echo "Including local bashrc"
fi
fi