-
Notifications
You must be signed in to change notification settings - Fork 1
/
test
executable file
·45 lines (36 loc) · 788 Bytes
/
test
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
#!/bin/bash
# This script tests the current ih-setup script by
# creating a new shell with the PATH set to include
# the ./bin directory.
# This can be destructive.
THIS_DIR=$(dirname "$(realpath "$0")")
BIN_DIR="$THIS_DIR/../bin"
function usage() {
cat <<USAGE
test SHELL
Creates a new instance of SHELL (zsh or bash) with the
current ih-setup script in the PATH.
USAGE
printf "\e[31m%b\e[0m" "Not starting a new shell."
exit 1
}
if [[ ${#} -eq 0 ]]; then
usage
fi
read -p "This command can damage your HOME or tools, are you sure? (y/N)" -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 0
fi
export PATH="$BIN_DIR:$PATH"
case $1 in
zsh)
zsh --nohashcmds --norcs
;;
bash)
bash -norc
;;
*)
usage
;;
esac