mailr28287 - /trunk/docs/bash_completion.sh


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on November 15, 2016 - 18:48:
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 = *




Related Messages


Powered by MHonArc, Updated Tue Nov 15 20:40:10 2016