source: utils/Bash/bash_completion@ dd6c07

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since dd6c07 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.