File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ _tykky_completions() {
2
+ if [ "${#COMP_WORDS[@]}" == "2" ]; then
3
+ COMPREPLY=($(compgen -W "activate deactivate" "${COMP_WORDS[1]}"))
4
+ return
5
+ fi
6
+ if [[ ${#COMP_WORDS[@]} -gt 2 ]]; then
7
+ if [[ "${COMP_WORDS[1]}" == "activate" && "${COMP_WORDS[2]}" != *"/"* ]]; then
8
+ local __tykky_env_list=""
9
+ local __tykky_path __candidate
10
+ local oldIFS=$IFS
11
+ IFS=:
12
+ for __tykky_path in ${TYKKY_PATH:-~/.tykky}; do
13
+ IFS=$oldIFS
14
+ for __candidate in $__tykky_path/*; do
15
+ if [[ -d "$__candidate" && -f "$__candidate/common.sh" && -d "$__candidate/bin" ]]; then
16
+ __tykky_env_list+="$(basename $__candidate) "
17
+ fi
18
+ done
19
+ done
20
+ COMPREPLY=($(compgen -W "$__tykky_env_list" "${COMP_WORDS[2]}"))
21
+ return
22
+ elif [[ "${COMP_WORDS[1]}" == "activate" && "${COMP_WORDS[2]}" == *"/"* ]]; then
23
+ COMPREPLY=( $(compgen -d -- "${COMP_WORDS[2]}") )
24
+ local i
25
+ for i in "${!COMPREPLY[@]}"; do
26
+ if [[ -d "${COMPREPLY[$i]}" && ! -f "${COMPREPLY[$i]}/common.sh" && ! -d "${COMPREPLY[$i]}/bin" ]]; then
27
+ COMPREPLY[$i]="${COMPREPLY[$i]}/"
28
+ fi
29
+ done
30
+ compopt -o nospace
31
+ fi
32
+ fi
33
+ return
34
+ }
35
+
36
+ complete -F _tykky_completions tykky
Original file line number Diff line number Diff line change @@ -91,3 +91,10 @@ tykky() {
91
91
;;
92
92
esac
93
93
}
94
+
95
+ # Enable BASH autocompletion
96
+ if [ -n " $BASH_VERSION " ] && [ -n " $PS1 " ]; then
97
+ __tykky_bash_completion_file=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) /../bash_completion.d/tykky_completion"
98
+ [ -f " $__tykky_bash_completion_file " ] && . " $__tykky_bash_completion_file "
99
+ unset __tykky_bash_completion_file
100
+ fi
You can’t perform that action at this time.
0 commit comments