-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-install
executable file
·59 lines (47 loc) · 1.04 KB
/
local-install
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
#!/bin/bash
set -e
[ ! -e install-functions.sh ] && echo -e "\e[31mThe installer must be started from bash-completer directory.\e[0m" && exit 1
readonly ROOT_DIR=$(pwd)
readonly TARGET_DIR="$HOME/.bash-completer"
if [[ $1 == "fast" ]]
then
if [ -d "$TARGET_DIR" ]
then
# Import the project
cp -R * "$TARGET_DIR"
else
mkdir -p "$TARGET_DIR"
# Import the project
cp -R * "$TARGET_DIR"
# Install
cd $TARGET_DIR
./install
fi
elif [[ $1 == "full" ]]
then
readonly TEMP_DIR="/tmp/bash-completer@save-$(date +%Y%m%d+%H%M)"
# Prepare the target folder
if [ -d "$TARGET_DIR" ]
then
cd "$TARGET_DIR"
# Save some data
mkdir -p "$TEMP_DIR"
cp -R __registered-programs "$TEMP_DIR"
# Clean
./uninstall
rm -r "$TARGET_DIR"/*
cd "$ROOT_DIR"
else
mkdir -p "$TARGET_DIR"
fi
# Import the project
cp -R * "$TARGET_DIR"
# Install
cd $TARGET_DIR
./install
# Restore previous files
cp -R "$TEMP_DIR"/* .
rm -rf "$TEMP_DIR"
else
echo "Select mode between 'fast' or 'full'"
fi