Skip to content

Commit

Permalink
Fall back to default completion after first argument
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaponte committed May 14, 2024
1 parent 7883be6 commit 7b30a29
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions bin/city-completion
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

0 comments on commit 7b30a29

Please sign in to comment.