This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homesick.sh
57 lines (49 loc) · 1.61 KB
/
homesick.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
#!/usr/bin/env bash
# ToDo: Review variables
function _homesick_completion()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Long options
if [[ ${cur} == -* ]] ; then
long_opts="--force --pretend --quiet --skip --no-pretend --no-quiet --no-skip"
COMPREPLY=( $(compgen -W "${long_opts}" -- ${cur}) )
return 0
fi
# Short options
if [[ ${cur} == - ]] ; then
short_opts="-f -p -q -s"
COMPREPLY=( $(compgen -W "${short_opts}" -- ${cur}) )
return 0
fi
# Command parameters
case "${prev}" in
cd|commit|destroy|diff|exec|link|open|pull|push|rc|show_path|status|unlink)
opts=$(homesick list | sed -e 's/^[ \t]*//' -e "s/ .*//g")
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
clone|exec_all|generate|track)
COMPREPLY=( $(compgen -f ${cur}) )
return 0
;;
list|version)
return 0
;;
*)
;;
esac
# Complete destination castle name on tracking a file or directory
if [[ "${COMP_WORDS[1]}" == "track" && "${prev}" ]]; then
opts=$(homesick list | sed -e 's/^[ \t]*//' -e "s/ .*//g")
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
# Commands
opts="cd clone commit destroy diff exec exec_all generate help link list open pull push rc show_path status track unlink version"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _homesick_completion homesick