Feature #1410

Future of shell completions

Added by Teemu Murtola about 7 years ago. Updated over 5 years ago.

core library
Target version:


With the implementation of #685, shell completions no longer work except when invoked through the legacy symlinks. Also, they can only be generated by the mkcompl script, which requires the symlinks (and likely requires some updates to work correctly in the presence of the gmx binary). If we want to remove those symlinks alltogether in the future, then the completions will become useless. contains RFC changes for implementing basic completion functionality for the wrapper binary, but has not received a single comment in the four months it has been out there. Currently, it only implements the completions for bash. IIRC, the last time the completion machinery was modified was some time in the early 2000's.

We should decide what we want to do with this and how much effort we want to spend here. In addition to the wrapper binary, another thing that requires a complete overhaul of the machinery that generates the completions is the use of the Options machinery for command-line parsing. We are not far from being able to extend to cover also the command-line parsing.

Possible alternatives:
  • Drop the completions completely.
  • Keep basic completion facilities, but only generate them for a single shell (e.g., bash, since that currently works). zsh should be able to use bash completions more or less directly. The only way to implement such complex completions for tcsh is a custom script, so that script could also redirect the actual work to a bash script.
  • Keep generating separate completions for the different shells. This requires someone who actually knows these shells to pitch in with the implementation, since I only have experience with bash. zsh seems ultra-flexible, and I could try to do something there. But tcsh is quite limited, so it can be difficult to get the same level of functionality there as for the other shells, and I don't have particular interests there. One option is to also just drop the tcsh completions if no one is interested in maintaining those.

Related issues

Related to GROMACS - Feature #685: Wrapper binaryClosed01/26/2011
Related to GROMACS - Bug #1159: Shell completions are partly brokenClosed02/26/2013
Related to GROMACS - Feature #969: Generating man pages, html help etc. from OptionsClosed07/12/2012

Associated revisions

Revision 04cc4266 (diff)
Added by Teemu Murtola almost 7 years ago

Shell completion export from the wrapper binary

Bash completions now complete the arguments to the wrapper binary
itself, as well as the subcommand names. After a subcommand has been
specified, use the existing completion logic. Completions now work also
for arbitrarily suffixed binaries (which the old system didn't work at
all). No completion is generated for symlinks, but should be
straightforward to do if really required; approach would be the same as

Other completions are not working for the wrapper binary, and as far as
I can tell, require a completely different approach. Removed the
non-functional code.

Related to #685 and #1410.

Change-Id: I55b13a65c176dab6e2f4f41bf6e829112c99e6b3

Revision 0d31fa51 (diff)
Added by Teemu Murtola almost 7 years ago

Fixes to filename shell completions

- When completing a file name, don't add a space after a directory name
has been completed.
- Don't exclude directory names starting with . from the completions.
This also excludes ../foobar/.
- Use a more reasonable pattern to match the file names: expect exactly
one of the acceptable extensions, and at most one .gz/.Z extension.
- Complete directory names for mdrun -multidir.

Issues that remain:
- Completions for paths that contain spaces doesn't really work.
The only difference to earlier behavior is that now, completing
something that starts with a " gets an appended space before the
closing ".
- When completing to subdirectories, the list of possible completions
shows the subdirectory for each alternative. This doesn't happen with
standard bash completion. Not sure whether this is feasible to fix.

Part of #1410 and #1159.

Change-Id: I1aff3ab89419e0ed4b53bc998c9a50b9a1879e9c

Revision e8d1bac3 (diff)
Added by Teemu Murtola almost 7 years ago

Fix shell completions of ffMULT options

Now file names for options with ffMULT set are completed also after one
file name has already been provided.

Fixes #1159, related to #1410.

Change-Id: I1f4f0b6a5817ce3193a0195d1cb4a2491c397593

Revision 12781054 (diff)
Added by Teemu Murtola almost 7 years ago

Shell completions through Options

- Implement shell completion generation for command line options
specified through an Options object.
- Use this support to generate the list of options for the wrapper
binary instead of hardcoding them.
- Use this support and the conversion from t_pargs/t_filenm to Options
to generate the existing completions. The only differences in the
generated completions are in the order of the options and in changing
"$n == 1" to "$n <= 1" and ".(xtc|trr|...)" to "(.xtc|.trr|...)".
- Extend some of the options to expose information necessary for this.

Related to #969 and #1410.

Change-Id: Ib77543367c38803ef186f6024a1af14feb806d80


#1 Updated by Teemu Murtola about 7 years ago

#2 Updated by Teemu Murtola about 7 years ago

  • Related to Bug #1159: Shell completions are partly broken added

#3 Updated by David van der Spoel about 7 years ago

I would vote for dropping the completions completely and turn the symlinks off by default.

#4 Updated by Szilárd Páll about 7 years ago

I think completition is rather useful for non-expert users and even I, with my moderate amount of experience, find it great that pressing TAB when looking for an input file will show me e.g. only the three tpr-s that are relevant as input instead of all 300 files in the respective directory.

Regarding the issue of providing full and tested functionality with multiple shells, this is IMO an ideal task to get help with from the GROMACS community. At least for bash and csh there should be people interested and willing to help - they may need some poking, though.

#5 Updated by Teemu Murtola about 7 years ago

  • Related to Feature #969: Generating man pages, html help etc. from Options added

#6 Updated by Mark Abraham almost 7 years ago

I invited some feedback on gmx-users.

I can see value in the bash completions, but none in doing separate work for the others unless someone wants to do it.

#7 Updated by Teemu Murtola almost 7 years ago now contains a relatively finished implementation of automatically generated bash completions. Other completions are simply dropped, since as far as I can tell, they require a completely different approach than what was used previously. I can provide support (e.g., refactor shellcompletions.cpp to more easily support export in multiple different formats) if someone gets to actually implement this for other shells. I'm not planning to do more for now; let's just wait for those contributions come flowing in…

If people really feel that this is such a great feature, it would be nice to get some review comments as well.

#8 Updated by Gerrit Code Review Bot almost 7 years ago

Gerrit received a related patchset '1' for Issue #1410.
Uploader: Teemu Murtola ()
Change-Id: I1aff3ab89419e0ed4b53bc998c9a50b9a1879e9c
Gerrit URL:

#9 Updated by Gerrit Code Review Bot almost 7 years ago

Gerrit received a related patchset '1' for Issue #1410.
Uploader: Teemu Murtola ()
Change-Id: I1f4f0b6a5817ce3193a0195d1cb4a2491c397593
Gerrit URL:

#10 Updated by Gerrit Code Review Bot almost 7 years ago

Gerrit received a related patchset '1' for Issue #1410.
Uploader: Teemu Murtola ()
Change-Id: Ib77543367c38803ef186f6024a1af14feb806d80
Gerrit URL:

#11 Updated by Mark Abraham about 6 years ago

  • Status changed from New to Resolved

With bash working and little interest in other shells, I think we are done here.

#12 Updated by Mark Abraham about 6 years ago

  • Target version changed from future to 5.0

#13 Updated by Teemu Murtola over 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF