-
Notifications
You must be signed in to change notification settings - Fork 1
/
bash_completion.sh
105 lines (93 loc) · 2.81 KB
/
bash_completion.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
_seedExtract() {
COMPREPLY=($(compgen -f -X '!*.zip' | sed -nr '/-'"$2"'[0-9]+.zip/ s/.*-([0-9]+).zip/\1/p'))
}
_prefabRules() {
if [[ -n $F7D2D ]]; then
COMPREPLY=( $(xmlstarlet sel -t -m "//prefab_rule[starts-with(@name,'$2')][prefab[@name]]" -v @name -n "${F7D2D}/Data/Config/rwgmixer.xml") )
else
COMPREPLY=()
fi
}
_prefabNames() {
COMPREPLY=()
if [[ -n $F7D2D ]]; then
while IFS= read -r -d '' dir; do
COMPREPLY+=( $(cd "${dir}" && compgen -f -- "$2" | sort -u | sed -e 's/\.[^ ]*//g') )
done < <(find "${F7D2D}/Data/Prefabs" -type d -print0)
fi
}
_special() {
if [[ "${COMP_CWORD}" == "1" ]]; then
BIN="$(cd "$(dirname "$(type -P withSpecial.sh)")" && pwd)"
: "${SPECIAL_FOLDER:=${BIN}/special}"
IFS=$'\n'
COMPREPLY=( $(cd "${SPECIAL_FOLDER}" && compgen -f -X '.*' -P '-' -- "${2#-}") )
IFS=$' \t\n'
else
_command "$@"
fi
}
_prefab() {
IFS=$'\n'
COMPREPLY=( $(compgen -o dirnames -o filenames -f -X '!*.xml' -- "$2") )
IFS=$' \t\n'
}
_image() {
IFS=$'\n'
COMPREPLY=( $(compgen -o dirnames -o filenames -f -X '!*.png' -- "$2") )
IFS=$' \t\n'
}
_size() {
nosuffix="${1%.*}"
noprefix="${nosuffix##*-}"
if [[ "$noprefix" =~ [0-9]+ ]]; then
COMPREPLY=( "$noprefix" )
else
COMPREPLY=( 4096 6144 8192 10240 )
fi
}
_prefabThenSpecial() {
if [[ "${COMP_CWORD}" == "1" ]]; then
_prefab "$@"
elif [[ "${COMP_CWORD}" == "2" ]]; then
BIN="$(cd "$(dirname "$(type -P withSpecial.sh)")" && pwd)"
: "${SPECIAL_FOLDER:=${BIN}/special}"
IFS=$'\n'
COMPREPLY=( $(cd "${SPECIAL_FOLDER}" && compgen -f -X '.*' -- "$2") )
IFS=$' \t\n'
fi
}
_imageThenSize() {
local nosuffix noprefix
if [[ "${COMP_CWORD}" == "1" ]]; then
_image "$@"
elif [[ "${COMP_CWORD}" == "2" ]]; then
_size "${COMP_WORDS[1]}"
fi
}
_seedName() {
COMPREPLY=( $(compgen -f -- "$2" | sed -e 's/\.[^ ]*//g') )
if [[ -d "$F7D2D/previews" ]]; then
COMPREPLY+=( $(cd "$F7D2D/previews" && compgen -f -- "$2" | sed -e 's/\.[^ ]*//g') )
fi
}
complete -F _seedExtract prefabs.sh
complete -F _prefabRules sortByRule.sh
complete -F _prefabNames -o filenames rulesWith.sh
complete -F _prefabNames -o filenames zoning.sh
complete -F _prefabNames -o filenames prefabSize.sh
complete -F _prefabNames -o filenames showPrefab.sh
complete -o dirnames -o filenames -f -X '!*.xml' uniquePrefabs.sh
complete -o dirnames -o filenames -f -X '!*.zip' uz.sh
complete -o dirnames -o filenames -f -X '!*.xml' prefabRules.sh
complete -o dirnames -o filenames -f -X '!*.xml' rate.py
complete -F _prefabThenSpecial missingPrefabs.sh
complete -F _prefabThenSpecial listSpecials.sh
complete -F _imageThenSize drawRate.sh
complete -F _command greatest.sh
complete -F _command tops.sh
complete -F _special withSpecial.sh
complete -F _seedName showSeed.sh
complete -F _seedName showBiomeDistribution.sh
complete -F _seedName showZoningDistribution.sh