Add initial support for python bindings
[alexxy/gromacs.git] / scripts / GMXRC.bash.cmakein
index 34941bd5a63a1e97e434d01113c2313c62663abe..eed26cafe75135267189a786f84660e611175624 100644 (file)
@@ -1,12 +1,17 @@
-# bash configuration file for Gromacs
+# sh/bash/zsh configuration file for Gromacs
 # First we remove old gromacs stuff from the paths
 # by selecting everything else.
 # This is not 100% necessary, but very useful when we
 # repeatedly switch between gmx versions in a shell.
 
+#we make use of IFS, which needs shwordsplit in zsh
+test -n "${ZSH_VERSION+set}" && setopt shwordsplit
+old_IFS="$IFS"
+IFS=":"
+
 # First remove gromacs part of ld_library_path
 tmppath=""
-for i in `echo $LD_LIBRARY_PATH | sed "s/:/ /g"`; do
+for i in $LD_LIBRARY_PATH; do
   if test "$i" != "$GMXLDLIB"; then
     tmppath="${tmppath}${tmppath:+:}${i}"
   fi
@@ -15,7 +20,7 @@ LD_LIBRARY_PATH=$tmppath
 
 # remove gromacs part of PKG_CONFIG_PATH
 tmppath=""
-for i in `echo $PKG_CONFIG_PATH | sed "s/:/ /g"`; do
+for i in $PKG_CONFIG_PATH; do
   if test "$i" != "$GMXLDLIB/pkgconfig"; then
     tmppath="${tmppath}${tmppath:+:}${i}"
   fi
@@ -24,7 +29,7 @@ PKG_CONFIG_PATH=$tmppath
 
 # remove gromacs part of path
 tmppath=""
-for i in `echo $PATH | sed "s/:/ /g"`; do
+for i in $PATH; do
   if test "$i" != "$GMXBIN"; then
     tmppath="${tmppath}${tmppath:+:}${i}"
   fi
@@ -33,7 +38,7 @@ PATH=$tmppath
 
 # and remove the gmx part of manpath
 tmppath=""
-for i in `echo $MANPATH | sed "s/:/ /g"`; do
+for i in $MANPATH; do
   if test "$i" != "$GMXMAN"; then
     tmppath="${tmppath}${tmppath:+:}${i}"
   fi
@@ -43,13 +48,15 @@ MANPATH=$tmppath
 ##########################################################
 # This is the real configuration part. We save the Gromacs
 # things in separate vars, so we can remove them later.
-# If you move gromacs, change the next four line.
+# If you move gromacs, change the first line.
 ##########################################################
-GMXBIN=@BIN_INSTALL_DIR@
-GMXLDLIB=@LIB_INSTALL_DIR@
-GMXMAN=@MAN_INSTALL_DIR@
-GMXDATA=@DATA_INSTALL_DIR@
-       
+GMXPREFIX=@CMAKE_INSTALL_PREFIX@
+GMXBIN=${GMXPREFIX}/@BIN_INSTALL_DIR@
+GMXLDLIB=${GMXPREFIX}/@LIB_INSTALL_DIR@
+GMXMAN=${GMXPREFIX}/@MAN_INSTALL_DIR@
+GMXDATA=${GMXPREFIX}/@DATA_INSTALL_DIR@
+GROMACS_DIR=${GMXPREFIX}
+
 LD_LIBRARY_PATH=${GMXLDLIB}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}
 PKG_CONFIG_PATH=${GMXLDLIB}/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}
 PATH=${GMXBIN}${PATH:+:}${PATH}
@@ -57,16 +64,29 @@ PATH=${GMXBIN}${PATH:+:}${PATH}
 MANPATH=${GMXMAN}:${MANPATH}
 
 # export should be separate, so /bin/sh understands it
-export GMXBIN GMXLDLIB GMXMAN GMXDATA LD_LIBRARY_PATH PATH MANPATH PKG_CONFIG_PATH
+export GMXBIN GMXLDLIB GMXMAN GMXDATA LD_LIBRARY_PATH PATH MANPATH
+export PKG_CONFIG_PATH GROMACS_DIR
+
+IFS="$old_IFS"
+unset old_IFS
 
 # read bash completions if understand how to use them
 # and this shell supports extended globbing
-if (complete) > /dev/null 2>&1; then
+if test -n "${BASH_VERSION+set}" && (complete) > /dev/null 2>&1; then
   if (shopt -s extglob) > /dev/null 2>&1; then
-    if [ -f $GMXBIN/completion.bash ]; then
-      source $GMXBIN/completion.bash; 
+    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
+# 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
-
-