forked from Chaostreff-Potsdam/erika3004
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate_autocomplete_for_erika_sh.sh
executable file
·43 lines (35 loc) · 1.59 KB
/
activate_autocomplete_for_erika_sh.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
#!/usr/bin/env bash
# ALTERNATIVE: activate tab completion for one script only (I have not tried this out successfully)
#eval "$(register-python-argcomplete erika.sh)"
echo "[ERIKA 3004] Activating script tab completion"
echo "[ERIKA 3004] (see https://argcomplete.readthedocs.io/en/latest/#global-completion )"
argcomplete_support_installed=$(type -P activate-global-python-argcomplete)
if [[ "$?" -ne 0 ]]; then
echo "[ERIKA 3004] Unexpected error (type -P)"
exit 1
fi
if [[ -z "${argcomplete_support_installed}" ]]; then
echo "[ERIKA 3004] FAILED. Install python requirements: pip3 install -r requirements.txt"
exit 1
fi
activate-global-python-argcomplete 1>/dev/null 2>/dev/null
if [[ "$?" -ne 0 ]]; then
echo "[ERIKA 3004] Direct installation FAILED."
echo "[ERIKA 3004] Instead, will generate a script instead..."
echo "[ERIKA 3004] activate-global-python-argcomplete --dest=- > /tmp/python-argcomplete.sh"
activate-global-python-argcomplete --dest=- > /tmp/python-argcomplete.sh
if [[ "$?" -ne 0 ]]; then
echo "[ERIKA 3004] Script generation FAILED as well. Exiting..."
exit 1
fi
echo "[ERIKA 3004] DONE"
echo "[ERIKA 3004] ...and copy it to the target directory then."
echo "[ERIKA 3004] THIS WILL REQUIRE SUDO ACCESS:"
echo "[ERIKA 3004] sudo cp /tmp/python-argcomplete.sh /etc/bash_completion.d"
sudo cp /tmp/python-argcomplete.sh /etc/bash_completion.d
if [[ "$?" -ne 0 ]]; then
echo "[ERIKA 3004] Copying the script FAILED. Exiting..."
exit 1
fi
fi
echo "[ERIKA 3004] tab completion successfully activated."