Author: bugman Date: Tue Nov 15 18:48:08 2016 New Revision: 28287 URL: http://svn.gna.org/viewcvs/relax?rev=28287&view=rev Log: Creation of an initial bash script for enabling bash completion.
Added: trunk/docs/bash_completion.sh (with props) Added: trunk/docs/bash_completion.sh URL: http://svn.gna.org/viewcvs/relax/trunk/docs/bash_completion.sh?rev=28287&view=auto ============================================================================== --- trunk/docs/bash_completion.sh (added) +++ trunk/docs/bash_completion.sh Tue Nov 15 18:48:08 2016 @@ -0,0 +1,92 @@ +############################################################################### +# # +# Copyright (C) 2016 Edward d'Auvergne # +# # +# This file is part of the program relax (http://www.nmr-relax.com). # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +# # +############################################################################### + +# Bash completion support for relax. +# +# To use this script, copy it to /etc/bash_completion.d/relax. + +_relax() { + # Define the variables. + local cur prev dir py_scripts opts + + # Initialise the COMPREPLY array. + COMPREPLY=() + + # Set the current and previous comp words. + 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. + opts="--help" + + # UI options. + opts="${opts} --prompt --gui --info --version --licence --test" + + # Multi-processor options. + opts="${opts} --multi --processors" + + # IO redirection options. + opts="${opts} --log --tee" + + # Test suite options. + opts="${opts} --test-suite --system-tests --unit-tests --gui-tests --verification-tests --time --no-skip" + + # Debugging options. + opts="${opts} --debug --error-state --traceback --escalate --numpy-raise" + + # Set COMPREPLY. + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + + # Success. + return 0 + + # Handle scripts. + else [[ ${cur} == * ]] + # Directories and Python scripts. + dir=$(echo .*/ */ 2> /dev/null) + py_scripts=$(/bin/ls *.py 2> /dev/null) + + # Set COMPREPLY. + COMPREPLY=( $(compgen -W "${dir} ${py_scripts}" -- ${cur}) ) + + # Success. + return 0 + + fi +} + +complete -F _relax relax Propchange: trunk/docs/bash_completion.sh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/docs/bash_completion.sh ------------------------------------------------------------------------------ svn:executable = * _______________________________________________ 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