forked from next-exp/IC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fall back to default completion after first argument
- Loading branch information
1 parent
7883be6
commit 7b30a29
Showing
1 changed file
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
#/usr/bin/env bash | ||
|
||
_city_completions () { | ||
for fullpath in `ls $ICTDIR/invisible_cities/cities/*.py`; do | ||
cityname=$(basename $fullpath) | ||
if [[ $cityname == *"test"* ]]; then continue; fi | ||
if [[ $cityname == *"components"* ]]; then continue; fi | ||
if [[ $cityname == "__"* ]]; then continue; fi | ||
if [[ $cityname == *"~" ]]; then continue; fi | ||
cityname=${cityname/.py/} | ||
COMPREPLY+=("$cityname") | ||
done | ||
PREV_WORD=${COMP_WORDS[COMP_CWORD-1]} | ||
|
||
if [[ ${PREV_WORD} == "city" ]]; then | ||
for fullpath in `ls $ICTDIR/invisible_cities/cities/*.py`; do | ||
cityname=$(basename $fullpath) | ||
if [[ $cityname == *"test"* ]]; then continue; fi | ||
if [[ $cityname == *"components"* ]]; then continue; fi | ||
if [[ $cityname == "__"* ]]; then continue; fi | ||
if [[ $cityname == *"~" ]]; then continue; fi | ||
cityname=${cityname/.py/} | ||
COMPREPLY+=("$cityname") | ||
done | ||
fi | ||
} | ||
|
||
complete -F _city_completions city | ||
complete -o default -F _city_completions city |