Author: bugman Date: Tue Nov 15 20:34:48 2016 New Revision: 28288 URL: http://svn.gna.org/viewcvs/relax?rev=28288&view=rev Log: Improvements for the bash completion relax script.
Directories and relax scripts are now much better handled. Modified: trunk/docs/bash_completion.sh Modified: trunk/docs/bash_completion.sh URL: http://svn.gna.org/viewcvs/relax/trunk/docs/bash_completion.sh?rev=28288&r1=28287&r2=28288&view=diff ============================================================================== --- trunk/docs/bash_completion.sh (original) +++ trunk/docs/bash_completion.sh Tue Nov 15 20:34:48 2016 @@ -34,20 +34,6 @@ cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - # Multi-processor option values. - case "${prev}" in - --multi) - COMPREPLY=( $(compgen -W "mpi4py" -- ${cur}) ) - return 0 - ;; - --processors) - COMPREPLY=( $(compgen -W "$(seq 2 257)" -- ${cur}) ) - return 0 - ;; - *) - ;; - esac - # Handle options. if [[ ${cur} == -* ]] ; then # The help options. @@ -73,20 +59,42 @@ # Success. return 0 + fi - # Handle scripts. - else [[ ${cur} == * ]] - # Directories and Python scripts. - dir=$(echo .*/ */ 2> /dev/null) - py_scripts=$(/bin/ls *.py 2> /dev/null) + # Multi-processor option values. + case "${prev}" in + --multi) + COMPREPLY=( $(compgen -W "mpi4py" -- ${cur}) ) + return 0 + ;; + --processors) + COMPREPLY=( $(compgen -W "$(seq 2 257)" -- ${cur}) ) + return 0 + ;; + *) + ;; + esac - # Set COMPREPLY. - COMPREPLY=( $(compgen -W "${dir} ${py_scripts}" -- ${cur}) ) + # Handle relax scripts which must end in *.py. + COMPREPLY=( $(compgen -f -X '!*.py' -- ${cur}) ) - # Success. + # Defer to _filedir for directory completion. + if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then + _filedir -d return 0 + fi + # Append a trailing '/' for unique directory names, if missing. + if [[ ${#COMPREPLY[@]} -eq 1 ]]; then + i=${COMPREPLY[0]} + if [[ "$i" == "${cur}" && $i != "*/" ]]; then + COMPREPLY[0]="${i}/" + fi + return 0 fi + + return 0 } -complete -F _relax relax +# Set up the completion for relax, avoiding trailing spaces for better subdirectory completion. +complete -o nospace -F _relax relax _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits