forked from jplhughes/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·55 lines (47 loc) · 1.44 KB
/
deploy.sh
File metadata and controls
executable file
·55 lines (47 loc) · 1.44 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
#!/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[@]}"
# Tmux setup
echo "source $DOT_DIR/config/tmux.conf" > $HOME/.tmux.conf
# Vimrc
if [[ $VIM == "true" ]]; then
echo "deploying .vimrc"
echo "source $DOT_DIR/config/vimrc" > $HOME/.vimrc
fi
# zshrc setup
echo "source $DOT_DIR/config/zshrc.sh" > $HOME/.zshrc
# Append additional alias scripts if specified
if [ -n "${ALIASES+x}" ]; then
for alias in "${ALIASES[@]}"; do
echo "source $DOT_DIR/config/aliases_${alias}.sh" >> $HOME/.zshrc
done
fi
chsh -s $(which zsh)
zsh