-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup
executable file
·54 lines (48 loc) · 1.25 KB
/
setup
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
#!/bin/bash
######################
# Bashelicious setup #
######################
trap 'cleanup; exit 1' HUP INT QUIT TERM
BASENAME=$(basename $0)
USAGE="Usage: $BASENAME {install | uninstall | reinstall}"
INSTALL_DIR=$HOME/.bashelicious
DIRECTORIES="lib plugins"
BASHRC_LINE="[[ -f $INSTALL_DIR/bashelicious ]] && . $INSTALL_DIR/bashelicious"
log_message() {
echo ":: $1"
}
case "$1" in
install)
if [ ! -d $INSTALL_DIR ]
then
mkdir $INSTALL_DIR
cp Bashelicious $INSTALL_DIR/bashelicious
for DIRECTORY in $DIRECTORIES
do
mkdir $INSTALL_DIR/$DIRECTORY
cp $DIRECTORY/* $INSTALL_DIR/$DIRECTORY
done
LINE=$(grep -n "${BASHRC_LINE}" $HOME/.bashrc | awk -F':' '{print $1;}')
[[ -z $LINE ]] && echo "${BASHRC_LINE}" >> $HOME/.bashrc
else
log_message "Bashelicious directory already exists (skipping)"
fi
echo ""
log_message "Bashelicious install complete!"
log_message "Restart your terminal or source your .bashrc file to load bashelicious"
echo ""
;;
uninstall)
LINE=$(grep -n "${BASHRC_LINE}" $HOME/.bashrc | awk -F':' '{print $1;}')
[[ -n $LINE ]] && sed -i -e "${LINE}d" $HOME/.bashrc
[[ -d $INSTALL_DIR ]] && rm -rf $INSTALL_DIR
;;
reinstall)
./$0 uninstall
./$0 install
;;
*)
echo $USAGE
exit 1
;;
esac