style(completions/django): Fix style

This commit is contained in:
Koichi Murase
2023-04-16 17:02:06 +09:00
parent 0c07172c02
commit 7965543018

View File

@@ -32,42 +32,43 @@
#
# To uninstall, just remove the line from your .bash_profile and .bashrc.
_django_completion()
{
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
DJANGO_AUTO_COMPLETE=1 $1 ) )
function _omb_completion_django {
COMPREPLY=($(COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
DJANGO_AUTO_COMPLETE=1 "$1"))
}
complete -F _django_completion -o default django-admin.py manage.py django-admin
complete -F _omb_completion_django -o default django-admin.py manage.py django-admin
_python_django_completion()
{
if [[ ${COMP_CWORD} -ge 2 ]]; then
PYTHON_EXE=$( basename -- "${COMP_WORDS[0]}" )
echo $PYTHON_EXE | command grep -E "python([2-9]\.[0-9])?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
PYTHON_SCRIPT=$( basename -- "${COMP_WORDS[1]}" )
echo $PYTHON_SCRIPT | command grep -E "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
if [[ $? == 0 ]]; then
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
COMP_CWORD=$(( COMP_CWORD-1 )) \
DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )
fi
fi
function _omb_completion_django_python {
if ((COMP_CWORD >= 2)); then
local PYTHON_EXE=$(basename -- "${COMP_WORDS[0]}")
if command grep -E "python([2-9]\.[0-9])?" >/dev/null 2>&1 <<< "$PYTHON_EXE"; then
local PYTHON_SCRIPT=$(basename -- "${COMP_WORDS[1]}")
if command grep -E "manage\.py|django-admin(\.py)?" >/dev/null 2>&1 <<< "$PYTHON_SCRIPT"; then
COMPREPLY=($(COMP_WORDS="${COMP_WORDS[*]:1}" \
COMP_CWORD=$((COMP_CWORD - 1)) \
DJANGO_AUTO_COMPLETE=1 "${COMP_WORDS[@]}"))
fi
fi
fi
}
# Support for multiple interpreters.
unset -v pythons
if _omb_util_command_exists whereis; then
function _omb_completion_django_init {
# Support for multiple interpreters.
local -a pythons=()
if _omb_util_command_exists whereis; then
local python_interpreters
_omb_util_split python_interpreters "$(whereis python | cut -d " " -f 2-)"
pythons=()
local python
for python in "${python_interpreters[@]}"; do
pythons+=("$(basename -- "$python")")
pythons+=("$(basename -- "$python")")
done
pythons=($(printf '%s\n' "${pythons[@]}" | sort -u))
else
_omb_util_split pythons "$(printf '%s\n' "${pythons[@]}" | sort -u)" $'\n'
else
pythons=(python)
fi
fi
complete -F _python_django_completion -o default "${pythons[@]}"
complete -F _omb_completion_django_python -o default "${pythons[@]}"
unset -f "$FUNCNAME"
}
_omb_completion_django_init