-
Notifications
You must be signed in to change notification settings - Fork 0
/
installBash.sh
executable file
·71 lines (61 loc) · 1.79 KB
/
installBash.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
#!/bin/bash
# ======================================================
# ======================|INFO|==========================
# Use: ./installBash.sh
# or ./installBash.sh [flags]
#
# flags:
# - (none) : Just install fpclock to your bash $PATH
# - v : Do it verbosely (print every step)
#
# ======================================================
# =====================|SCRIPT|=========================
appname="fpclock"
appexec="fpclock"
verbose=0
if [[ ${BASH_ARGV[0]} =~ v ]] ;
then
verbose=1
fi
if [ $verbose -eq 1 ] ;
then
echo "Starting..."
echo "Creating directory $HOME/bin... (unless exists)"
fi
mkdir -p $HOME/bin
if [ $? -ne 0 ] ; then
echo "Error when creating or finding directory $HOME/bin."
else
if [ $verbose -eq 1 ] ; then
echo "Done!";
echo "Copying $appname to $HOME/bin..."
fi
cp ./$appexec $HOME/bin/$appexec
if [ $? -ne 0 ] ; then
echo "Error when copying $appname to $HOME/bin."
else
if [ $verbose -eq 1 ] ; then
echo "Done!";
echo "Setting up \$PATH..."
fi
if grep -Fxq "export PATH=$HOME/bin:\$PATH" $HOME/.bashrc ;
then
if [ $verbose -eq 1 ] ; then
echo "It looks like you've already installed \$PATH on $HOME/bin."
echo "I've just updated your $appname executable."
fi
echo "Installation of $appname to your bash \$PATH has been finished with success!"
echo "Type '$appexec' in your command prompt to check out the program then."
else
echo "# Set up a $appname path" >> $HOME/.bashrc
echo "export PATH=$HOME/bin:\$PATH" >> $HOME/.bashrc
source $HOME/.bashrc
if [ $? -eq 0 ] ; then
echo "Installation of $appname to your bash \$PATH has been finished with success!"
echo "Type '$appexec' in your command prompt to check out the program."
else
echo "Error when setting up \$PATH."
fi
fi
fi
fi