This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
forked from majkelcc/chang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·69 lines (55 loc) · 1.48 KB
/
install
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
#!/bin/bash
set -eu
[email protected]:majkelcc/chang.git
DEFAULT_CHANG_HOME=${CHANG_HOME:-~/.chang}
echo -n "Install chang to (defaults to ${DEFAULT_CHANG_HOME/$HOME/~}): "
read chang_home
eval chang_home="${chang_home%/}" # use eval to expand ~ if present
chang_home="${chang_home:-${DEFAULT_CHANG_HOME}}"
if [[ -d "$chang_home" ]]; then
echo "Directory ${chang_home} exists, skipping"
else
mkdir -p "$chang_home"
git clone $REPOSITORY_URL "$chang_home"
fi
if [[ -z ${CHANG_HOME:-} ]]; then
bashrc=
if [[ -f ~/.bash_profile ]]; then
bashrc=~/.bash_profile
elif [[ -f ~/.bashrc ]]; then
bashrc=~/.bashrc
fi
if [[ -n $bashrc ]]; then
echo -n "Install chang in ${bashrc/$HOME/~}? (Y/n): "
read y
if [[ -z $y || $y == "y" ]]; then
echo
echo "Installing chang in ${bashrc/$HOME/~}"
cat <<EOF | tee -a "$bashrc"
export CHANG_HOME=${chang_home/$HOME/~}
export PATH="\$CHANG_HOME/bin:\$PATH"
source \$CHANG_HOME/chang-bash-completion
EOF
fi
fi
zshrc=
if [[ -f ~/.zshrc ]]; then
zshrc=~/.zshrc
fi
if [[ -n $zshrc ]]; then
echo -n "Install chang in ${zshrc/$HOME/~}? (Y/n): "
read y
if [[ -z $y || $y == "y" ]]; then
echo
echo "Installing chang in ${zshrc/$HOME/~}"
cat <<EOF | tee -a "$zshrc"
export CHANG_HOME=${chang_home/$HOME/~}
export PATH="\$CHANG_HOME/bin:\$PATH"
source \$CHANG_HOME/chang-zsh-completion
EOF
fi
fi
fi
echo
echo "Chang installed 🐳"
echo "(open a new shell to use it)"