Opened 8 years ago

Closed 5 years ago

Last modified 3 years ago

#945 closed Enhancement (fixed)

bash completion for makenemo

Reported by: rkandilarov Owned by: vichi
Priority: low Milestone: Unscheduled
Component: tools Version: release-3.4
Severity: Keywords: bash makenemo
Cc: Review:
MP ready?:


I want to get familiar with making my own bash complition functions and spend some time over a bash completion file for makenemo and would like to share it:). 

I know that probably only 1% of the time makenemo is called interactivly (not from script) but for people like me wich seems to forget the avaliable options it could be usefull.

There several tricks that one have to know about this function(s):

  • currently an "echo -e" is used for multiline print which AFAR is not posix, so porting it to non linux(AIX for example) systems needs the use of "printf" instead (but I'm too lazy to do it now :) );
  • if makenemo is in the $PATH it should be located in NEMOGCM/CONFIG (the default) and all the complition is done relatively to this directory, using $(dirname $(which ${COMP_WORDS[0]})) ), so that it really could be runned from anyware (as it is now);
  • the "add_key" and "del_key" compliton follows the makenemo logic (as I understand it :) ) - if "-r ANYTHING" is given its argument is used, if not - the argument of "-n OTHER_THING" is used. In case non of them is given the default ( last of cfg.txt) is used;
  • if ones wants to use the add_key completion functionality a file called NEMOGCM/CONFIG/YourConfigName/cpp_all_YourConfigName.fcm  have to be created containing a space separated list of all possible keys for YourConfigName. If fact I don't see any easy way to get all the possible keys in one configuration except greping recursively. It will be great if makenemo generates such file.
  • the function can complete multiple keys (add_key, del_key) and several folders (-d) but one have to press backspace and delete the closing quotes(") in order to start the completion mechanism for the n-th key;
  • there are some features that can make you not so happy - if the written text doesnt mach the complition it could be removed… I left it only for some cases that I knew the option/argument is wrong.


Commit History (0)

(No commits)

Attachments (3) (6.5 KB) - added by rkandilarov 8 years ago. (8.7 KB) - added by rkandilarov 8 years ago.
diff_maketools (535 bytes) - added by rkandilarov 8 years ago.

Download all attachments as: .zip

Change History (12)

Changed 8 years ago by rkandilarov

Changed 8 years ago by rkandilarov

Changed 8 years ago by rkandilarov

comment:1 Changed 8 years ago by rkandilarov

So I have to make the "echo -e" to "printf" transition cause found the script being buggy…Here are both the new bugfixed version having also the maketools completion and the patch to maketools in order to make it runnable regardless the current path…

comment:2 Changed 8 years ago by clevy

  • Owner changed from NEMO team to vichi

comment:3 Changed 8 years ago by vichi

  • Status changed from new to assigned

Hi Rostislav, sorry for being so late in getting back to you. Your contribution is very interesting and much appreciated.
I am testing it on several architectures and everything works great apart the -d where I get the following error

./makenemo -n NEWCONF -d -bash: COMP_WORDS: bad array subscript

and if I put the " sign I get

./makenemo -n NEW -d "expr: syntax error

also, it looks like that even if the argument "-n CONFIG" is used, the last configuration in cfg.txt is searched for, as for instance

./makenemo -n ORCA2_LIM add_key "expr: syntax error
cat: ./GYRE_BFM/cpp_all_GYRE_BFM.fcm: No such file or directory

We do agree that the list of available cpp keys should be generated by FCM, but it looks like it is not so easy.

comment:4 Changed 5 years ago by clevy

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:5 Changed 4 years ago by nicolasmartin

  • Keywords completion removed

comment:6 Changed 3 years ago by nemo

  • Keywords CFG_TOOLS added

comment:7 Changed 3 years ago by nemo

  • Keywords Misc. added

comment:8 Changed 3 years ago by nemo

  • Keywords CFG_TOOLS removed

comment:9 Changed 3 years ago by nemo

  • Keywords Misc. removed
Note: See TracTickets for help on using tickets.