-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·61 lines (51 loc) · 1.58 KB
/
deploy.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.58 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
#!/bin/bash
set -euo pipefail
USAGE=$(cat <<-END
Usage: ./deploy.sh [OPTIONS] [--aliases <alias1,alias2,...>], eg. ./deploy.sh --vim --aliases=speechmatics,custom
Creates ~/.zshrc and ~/.tmux.conf with location
specific config
OPTIONS:
--vim deploy very simple vimrc config
--aliases specify additional alias scripts to source in .zshrc, separated by commas
END
)
export DOT_DIR=$(dirname $(realpath $0))
VIM="false"
ALIASES=()
while (( "$#" )); do
case "$1" in
-h|--help)
echo "$USAGE" && exit 1 ;;
--vim)
VIM="true" && shift ;;
--aliases=*)
IFS=',' read -r -a ALIASES <<< "${1#*=}" && shift ;;
--) # end argument parsing
shift && break ;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2 && exit 1 ;;
esac
done
echo "deploying on machine..."
#echo "using extra aliases: ${ALIASES[@]}"
append_once() {
local line="$1" target="$2"
grep -qxF "$line" "$target" 2>/dev/null || echo "$line" >> "$target"
}
# Tmux setup
append_once "source $DOT_DIR/config/tmux.conf" "$HOME/.tmux.conf"
# Vimrc
if [[ $VIM == "true" ]]; then
echo "deploying .vimrc"
append_once "source $DOT_DIR/config/vimrc" "$HOME/.vimrc"
fi
# zshrc setup
append_once "source $DOT_DIR/config/zshrc.sh" "$HOME/.zshrc"
if [ -n "${ALIASES+x}" ]; then
for alias in "${ALIASES[@]}"; do
append_once "source $DOT_DIR/config/aliases_${alias}.sh" "$HOME/.zshrc"
done
fi
echo "changing default shell to zsh"
chsh -s $(which zsh)
zsh