-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·64 lines (53 loc) · 1.42 KB
/
install.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
#!/usr/bin/env bash
set -e
BIN_PATH=$HOME/.local/bin
BIN_NAME=parnas
WRAPPER_URL='https://raw.githubusercontent.com/sndl/parnas/master/parnas.sh'
download_wrapper () {
mkdir -p ${BIN_PATH}
curl -s ${WRAPPER_URL} -o ${BIN_PATH}/${BIN_NAME}
chmod +x ${BIN_PATH}/${BIN_NAME}
}
check_path () {
if [[ $(echo $PATH | grep ${BIN_PATH}) == "" ]]; then
echo "Looks like $BIN_PATH is not in path. Would you like to set it automatically? (yes/no):"
read confirmation
[[ ${confirmation} == "yes" ]] && set_path
fi
}
set_path () {
local sh_rc_path=''
local export_path=''
case $SHELL in
/bin/bash)
sh_rc_path=$HOME/.bashrc
export_path='export PATH="$HOME/.local/bin:$PATH"'
;;
/bin/zsh)
sh_rc_path=$HOME/.zshrc
export_path='export PATH="$HOME/.local/bin:$PATH"'
;;
/bin/tcsh)
sh_rc_path=$HOME/.tcshrc
export_path='set path = ($path $HOME/.local/bin)'
;;
/bin/kshrc)
sh_rc_path=$HOME/.kshrc
export_path='export PATH="$HOME/.local/bin:$PATH"'
;;
/bin/fish)
sh_rc_path=$HOME/.config/fish/config.fish
export_path='set -gx PATH $HOME/.local/bin $PATH'
;;
*)
echo "Unknown shell: $SHELL"
exit 1
esac
grep -qxF "${export_path}" ${sh_rc_path} || echo ${export_path} >> ${sh_rc_path}
}
main () {
download_wrapper
check_path
}
main
exit 0