Skip to content

Commit

Permalink
fix bash completion path bug in more recent bash versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Feb 4, 2025
1 parent 6f95462 commit f2d6655
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions django_typer/templates/shell_complete/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,21 @@
done < <( $1 {{ django_command }} --shell bash ${settings_option:+${settings_option}} ${pythonpath_option:+${pythonpath_option}} {{ color }} complete {{ fallback }} "${COMP_WORDS[*]}" )

COMPREPLY=()
set_mode=true
for completion in "${response[@]}"; do
IFS=',' read type value <<< "$completion"

{% if use_compopt %}
if [[ $type == 'dir' ]]; then
COMPREPLY=()
compopt -o dirnames
elif [[ $type == 'file' ]]; then
COMPREPLY=()
compopt -o default
else
COMPREPLY+=($value)
if $set_mode; then
if [[ $type == 'dir' ]]; then
compopt -o dirnames
elif [[ $type == 'file' ]]; then
compopt -o default
set_mode=false
fi
fi
{% else %}
COMPREPLY+=($value)
{% endif %}
COMPREPLY+=($value)
done

return 0
Expand Down

0 comments on commit f2d6655

Please sign in to comment.