-
Notifications
You must be signed in to change notification settings - Fork 1
/
gotoFct.sh
46 lines (37 loc) · 1.53 KB
/
gotoFct.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
used_shell=`ps -hp $$|awk 'END {print $NF;}'`
if [[ $used_shell == *"bash"* ]]; then
my_dir="$(dirname "${BASH_SOURCE[0]}")"
elif [[ $used_shell == *"zsh"* ]]; then
my_dir="$(dirname "$0")"
fi
#
# ─── FUNCTIONS ──────────────────────────────────────────────────────────────────
#
source $my_dir/gotoFct_functions.sh
#
# ─── INIT ───────────────────────────────────────────────────────────────────────
#
if [[ $used_shell == *"zsh"* ]]; then
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
fi
#if [[ $used_shell == "/usr/bin/zsh" ]]; then
#else
# complete -W "-a -r -l -h" goto
#fi
complete -F goto_completion goto
#
# ─── MAIN ───────────────────────────────────────────────────────────────────────
#
function goto(){
if [ ! -e "~/.gotoFct" ]; then
touch ~/.gotoFct
fi
case $1 in
"-l"|"--list"|"list") goto_list;;
"-a"|"--add"|"add") goto_add "${@:2}";;
"-r"|"--remove"|"remove") goto_remove ${@:2};;
"-h"|"--help"|"help") goto_help;;
*) goto_goto $@;;
esac
}