-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall_zsh.sh
executable file
·74 lines (61 loc) · 1.76 KB
/
install_zsh.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
#!/usr/bin/env zsh
set -eu
# =======
# Defaults
# =======
ZPREZTO_DIR=${ZPREZTO_DIR:-"${HOME}/.zprezto"}
GIT=${GIT:-'git'}
REPO_ADDRESS=${REPO_ADDRESS:-'https://github.com/holser/dotfiles.git'}
function link_file {
source="${PWD}/$1"
target="${HOME}/$1"
if [ -f "${target}" ]; then
mv ${target}{,.$(date +%F).bak}
fi
ln -sf ${source} ${target}
}
function check_binary {
if [ -z $1 ]; then
echo "No arguments found"
exit 1
fi
if ! command -v $1; then
echo "$1 was not found. Please install it"
fi
}
check_binary $GIT
check_binary curl
if [[ $(dscl . -read /Users/${USER} UserShell) =~ 'zsh$' ]]; then
echo "zsh is already set"
else
echo "Current shell is not zsh, setting zsh for current user"
sudo dscl . -create /Users/${USER} UserShell /bin/zsh
fi
if [ -d "${ZPREZTO_DIR}" ]; then
pushd ${ZPREZTO_DIR}
${GIT} pull origin master
popd
else
# Grab prezto code
${GIT} clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZPREZTO_DIR}"
fi
if [ -d ~/.dotfiles ]; then
pushd ~/.dotfiles/
${GIT} pull origin master
popd
else
${GIT} clone ${REPO_ADDRESS} ~/.dotfiles
fi
# Installing prezto configs except zshrc and zpreztorc
for rcfile in $(find "${ZPREZTO_DIR}"/runcoms -type f \( ! -name README.md ! -name zpreztorc ! -name zshrc \)); do
echo "Linking ${rcfile}"
ln -sf "${rcfile}" "${HOME}/.${rcfile:t}"
done
# Download my favourite theme
curl -sSL https://gist.githubusercontent.com/wikimatze/4c2fbaf8ebe1e8ce0c1f/raw/ed34a873ab0be5dc687b8047eb1912afabaa2014/prompt_wikimatze_setup > "${ZPREZTO_DIR}"/modules/prompt/functions/prompt_wikimatze_setup
pushd ~/.dotfiles
for file in ".zshrc" ".zpreztorc" ".aliases"; do
link_file $file
done
popd
unset file