-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-functions.sh
96 lines (76 loc) · 2.11 KB
/
install-functions.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Checks the dependencies
# Echoes the list of elements missing
checkDependencies() {
if [ ! -d /etc/bash_completion.d ]
then
echo "bash-completion"
fi
type getopt &> /dev/null || echo "getopt"
return 0
}
# Checks the optional packages and binaries that could be installed
# Echoes the list of elements missing
checkOptionals() {
type ruby &> /dev/null || echo "ruby"
return 0
}
# Echoes a list
# $1 pre-message
# $2 post-message
# $* package list
echoPackageList () {
local preMessage="$1"
local postMessage="$2"
shift 2
echo -en $preMessage
for package in $*
do
echo "\n* $package"
done
echo -e "\n$postMessage"
return 0
}
COMPLETION_SCRIPT=/etc/bash_completion.d/bash-completer
COMPLETION_BINARY=/usr/bin/bash-completer
install() {
sudo ln -s $PWD/__completer $COMPLETION_SCRIPT
sudo ln -s $PWD/bin/bash-completer $COMPLETION_BINARY
# reload the completion file to reset the environment
bashOptions=$-
set +e
source $COMPLETION_SCRIPT
[[ "$bashOptions" == *e* ]] && set -e
return 0
}
uninstall() {
sudo rm -f $COMPLETION_SCRIPT $COMPLETION_BINARY
return 0
}
usage() {
cat <<USAGE
Usage: ./install [options]
Options:
-h --help prints this message
--notes prints installation notes
USAGE
}
echoNotes() {
echo -ne "\e[34m"
cat <<NOTES
Bravo ! The installation is complete.
You can now start to register programs for completion.
To help you in your programming, we advise you to add the following variables to your environment.
>> PYTHONPATH=\$PYTHONPATH:\$HOME/.bash-completer/lib
>> RUBYLIB=\$RUBYLIB:\$HOME/.bash-completer/lib
The bash-completer has been installed in ~/.bash-completer. It's important that you do not move it to another location.
Otherwise, the program will stop to work.
To uninstall this, go to ~/.bash-completer and execute th uninstaller
cd ~/.bash-completer
./uninstall
Up to now, there is no system to update automatically your version of bash-completer.
Just uninstall and reinstall everything if a newer version comes up.
One more note:
You can always review this message by executing ./install --notes
NOTES
echo -e "Bye ...\e[0m"
}