-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·61 lines (48 loc) · 1.45 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
#!/bin/bash
set -euo pipefail
USAGE=$(cat <<-END
Usage: ./deploy.sh [OPTIONS], eg. ./deploy.sh --local --vim
Creates ~/.zshrc and ~/.tmux.conf with location
specific config
OPTIONS:
--local deploy local config only, only common aliases are sourced
--vim deploy very simple vimrc config
END
)
export DOT_DIR=$(dirname $(realpath $0))
LOC="remote"
VIM="false"
while (( "$#" )); do
case "$1" in
-h|--help)
echo "xq$USAGE" && exit 1 ;;
--local)
LOC="local" && shift ;;
--vim)
VIM="true" && shift ;;
--) # end argument parsing
shift && break ;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2 && exit 1 ;;
esac
done
# Tmux setup
echo "source $DOT_DIR/config/tmux.conf" > $HOME/.tmux.conf
base_config=$(cat <<-END
[include]
path = $DOT_DIR/config/gitconf/git.config
END
)
echo "$base_config" > $HOME/.gitconfig
# Vimrc
if [[ $VIM == "true" ]]; then
echo "deploying .vimrc"
echo "source $DOT_DIR/config/vimrc" > $HOME/.vimrc
fi
# prepend the sourcing of zshrc to the file, so that we don't delete it every time
if ! grep -q "source $DOT_DIR/config/zshrc.sh" $HOME/.zshrc; then
echo "source $DOT_DIR/config/zshrc.sh" | cat - $HOME/.zshrc > temp && mv temp $HOME/.zshrc
fi
# drop me into zsh shell by default
echo 'if [[ $- == *i* ]];then exec zsh;fi' > $HOME/.bashrc
zsh