-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pass --settings and --pythonpath to complete on zshell, #68
- Loading branch information
Showing
2 changed files
with
26 additions
and
3 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,7 +1,30 @@ | ||
#compdef %(prog_name)s | ||
|
||
%(complete_func)s() { | ||
eval $(env _TYPER_COMPLETE_ARGS="${words[1,$CURRENT]}" %(autocomplete_var)s=complete_zsh ${words[0,1]} {{ django_command }} {{ color }} complete) | ||
|
||
# Extract --settings and --pythonpath options and their values if present becase | ||
# we need to pass these to the complete script - they may be necessary to find the command! | ||
local settings_option="" | ||
local pythonpath_option="" | ||
|
||
for ((i=1; i<$CURRENT; i++)); do | ||
case "${words[i]}" in | ||
--settings) | ||
# Only pass settings to completion script if we're sure it's value does not itself need completion! | ||
if (( i + 1 < CURRENT )) && [[ -n "${words[i+1]}" ]] && [[ "${words[i+1]}" != --* ]]; then | ||
settings_option="--settings=${words[i+1]}" | ||
fi | ||
;; | ||
--pythonpath) | ||
# Only pass pythonpath to completion script if we're sure it's value does not itself need completion! | ||
if (( i + 1 < CURRENT )) && [[ -n "${words[i+1]}" ]] && [[ "${words[i+1]}" != --* ]]; then | ||
pythonpath_option="--pythonpath=${words[i+1]}" | ||
fi | ||
;; | ||
esac | ||
done | ||
|
||
eval $(env _TYPER_COMPLETE_ARGS="${words[1,$CURRENT]}" %(autocomplete_var)s=complete_zsh ${words[0,1]} {{ django_command }} ${settings_option:+${settings_option}} ${pythonpath_option:+${pythonpath_option}} {{ color }} complete) | ||
} | ||
|
||
compdef %(complete_func)s %(prog_name)s |
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