source: utils/Bash/bash_completion@ 440ac3

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 440ac3 was 9fd196, checked in by Frederik Heber <heber@…>, 13 years ago

Added bash_completion file.

  • use as . utils/Bash/bash_completion, installed in bin folder.
  • moved all python files in utils into subfolder Python therein.
  • We scan molecuilder's help output for the present actions and return in COMPREPLY, fully capable of giving option to last action and all available actions in any other case.
  • we expand files if no "--" is given.
  • TESTFIX: Python/BoxMaker needs to call boxmaker.py from utils/Python.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1# bash_completion for molecuilder
2#
3# gives a list of all available actions, gives list of options for the last action
4
5function _molecuilder_option()
6{
7 local cmd="${1##*/}"
8 local word=${COMP_WORDS[COMP_CWORD]}
9 local line=${COMP_LINE}
10 option=`echo $line | awk -F"--" {'print $NF'} | tr -d \ `
11 previousoption=`echo $line | awk -F"--" {'print $(NF-1)'} | tr -d \ `
12 #echo "current option is '$word', line is '$line', and cmd is '$cmd', last option is '$option', and last but one is '$previousoption'."
13 COMPREPLY=()
14 # if current option is molecuilder, give all available actions
15 if test x"$option" = x"molecuilder"; then
16 # "molecuilder "
17 COMPREPLY=($($cmd --help | grep "^'.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
18 else
19 # if current argument is void, look at previous (if its not molecuilder)
20 if test x"$option" = x""; then
21 if test x"$previousoption" = x"molecuilder"; then
22 # "molecuilder --"
23 COMPREPLY=($($cmd --help | grep "^'.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
24 else
25 # "molecuilder --some-action --"
26 COMPREPLY=($($cmd --help | grep "^'$previousoption.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
27 if test ${#COMPREPLY[*]} -eq 0; then
28 # "molecuilder --some-option --"
29 COMPREPLY=($($cmd --help | grep "^'.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
30 else
31 COMPREPLY=($($cmd --help --actionname "$previousoption" | grep Option\ | awk -F"'" {'print "--"$2'} | tr -d \'))
32 # if action has no options, give list of actions
33 if test ${#COMPREPLY[*]} -eq 0; then
34 COMPREPLY=($($cmd --help | grep "^'.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
35 fi
36 fi
37 fi
38 elif test -z `echo "$word" 2>/dev/null | grep "\-\-"`; then
39 # "molecuilder somefile/value"
40 COMPREPLY=( $( compgen -W "$( ls --color=n -1 ${word}*.in ${word}*.pdb ${word}*.pcp ${word}*.psi ${word}*.data ${word}*.xyz 2>/dev/null| sed -e 's/ /\\ /g' )" -- $cur ))
41 else
42 # "molecuilder --something"
43 COMPREPLY=($($cmd --help | grep "^'$option.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
44 # check whether its an action
45 if test ${#COMPREPLY[*]} -eq 1; then
46 # check whether it's same as option
47 if test x"${COMPREPLY[0]}" = x"--$option"; then
48 # "molecuilder --an-action"
49 #echo "Giving help for option $option"
50 COMPREPLY=($($cmd --help --actionname "$option" | grep Option\ | awk -F"'" {'print "--"$2'} | tr -d \'))
51 # if action has no options, give list of actions
52 if test ${#COMPREPLY[*]} -eq 0; then
53 COMPREPLY=($($cmd --help | grep "^'.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
54 fi
55 fi
56 fi
57 # if the "action" is unknown, it must be actually an option (segment), give all available options from previous action
58 if test ${#COMPREPLY[*]} -eq 0; then
59 # "molecuilder --an-action --opt.."
60 COMPREPLY=($($cmd --help --actionname "$previousoption" | grep Option\ | grep $option | awk -F"'" {'print "--"$2'} | tr -d \'))
61 # if action has no options, give list of actions
62 if test ${#COMPREPLY[*]} -eq 0; then
63 COMPREPLY=($($cmd --help | grep "^'.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
64 else
65 #if we have a complete option, give again all available actions
66 if test x"${COMPREPLY[0]}" = x"--$option"; then
67 # "molecuilder --an-action --one-of-its-options"
68 COMPREPLY=($($cmd --help | grep "^'.*'" | awk -F":" {'print "--"$1'} | tr -d \'))
69 fi
70 fi
71 fi
72 fi
73 fi
74 #echo "returning ${COMPREPLY[*]}."
75 return 0
76}
77
78complete -F _molecuilder_option molecuilder
Note: See TracBrowser for help on using the repository browser.