From: James W. Barnett Date: Tue, 14 Jul 2015 23:24:40 +0000 (-0500) Subject: Implement zsh shell completions. X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?p=alexxy%2Fgromacs.git;a=commitdiff_plain;h=6990a0a5035c28011ee8a667df19d4ff0fc3b3d1 Implement zsh shell completions. zsh completions when gmx prefix was used were not implemented. Use zsh builtin bashcompinit to use the bash completions. Remove 'shopt -s extglob' from gmx-completion.bash and place it in GMXRC.bash, since it is incompatible with zsh. gmx-completion.bash and gmx-completion-gmx.bash can now be used for completions in both bash and zsh. Change-Id: Ib8f3cf0535d39e91a6b31933f41aa7548755b351 --- diff --git a/scripts/GMXRC.bash.cmakein b/scripts/GMXRC.bash.cmakein index eed26cafe7..18457a6377 100644 --- a/scripts/GMXRC.bash.cmakein +++ b/scripts/GMXRC.bash.cmakein @@ -74,6 +74,18 @@ unset old_IFS # and this shell supports extended globbing if test -n "${BASH_VERSION+set}" && (complete) > /dev/null 2>&1; then if (shopt -s extglob) > /dev/null 2>&1; then + shopt -s extglob + if [ -f $GMXBIN/gmx-completion.bash ]; then + source $GMXBIN/gmx-completion.bash + for cfile in $GMXBIN/gmx-completion-*.bash ; do + source $cfile + done + fi + fi +elif test -n "${ZSH_VERSION+set}" > /dev/null 2>&1 ; then + autoload bashcompinit + if (bashcompinit) > /dev/null 2>&1; then + bashcompinit if [ -f $GMXBIN/gmx-completion.bash ]; then source $GMXBIN/gmx-completion.bash for cfile in $GMXBIN/gmx-completion-*.bash ; do @@ -81,12 +93,4 @@ if test -n "${BASH_VERSION+set}" && (complete) > /dev/null 2>&1; then done fi fi -# read zsh completions if understand how to use them -# Currently disabled, since the completions don't work with the new -# gmx binary with subcommands. -# Contributions to get the functionality back are welcome. -#elif test -n "${ZSH_VERSION+set}" && compctl >& /dev/null; then -# if [ -f $GMXBIN/gmx-completion.zsh ]; then -# source $GMXBIN/gmx-completion.zsh; -# fi fi diff --git a/src/gromacs/commandline/shellcompletions.cpp b/src/gromacs/commandline/shellcompletions.cpp index 1eefeda1cf..ce9f08a717 100644 --- a/src/gromacs/commandline/shellcompletions.cpp +++ b/src/gromacs/commandline/shellcompletions.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -218,7 +218,6 @@ File *ShellCompletionWriter::outputFile() void ShellCompletionWriter::startCompletions() { impl_->file_.reset(new File(impl_->binaryName_ + "-completion.bash", "w")); - impl_->file_->writeLine("shopt -s extglob"); } void ShellCompletionWriter::writeModuleCompletions(