Skip to content

Shells and mepo

Matthew Thompson edited this page Nov 19, 2020 · 3 revisions

mepo provides a few helper shell functions to make things easier

mepo-cd

mepo-cd is a helper shell function (alias in csh) that uses mepo whereis information to move you around the repositories. So for example:

mepo whereis
GEOSgcm                | .
env                    | @env
cmake                  | @cmake
ecbuild                | @cmake/@ecbuild
NCEP_Shared            | src/Shared/@NCEP_Shared
GMAO_Shared            | src/Shared/@GMAO_Shared
MAPL                   | src/Shared/@MAPL
FMS                    | src/Shared/@FMS
GEOSgcm_GridComp       | src/Components/@GEOSgcm_GridComp
FVdycoreCubed_GridComp | src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSsuperdyn_GridComp/@FVdycoreCubed_GridComp
fvdycore               | src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSsuperdyn_GridComp/@FVdycoreCubed_GridComp/@fvdycore
GEOSchem_GridComp      | src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/@GEOSchem_GridComp
mom                    | src/Components/@GEOSgcm_GridComp/GEOSogcm_GridComp/GEOSocean_GridComp/GuestOcean_GridComp/MOM_GEOS5PlugMod/@mom
mom6                   | src/Components/@GEOSgcm_GridComp/GEOSogcm_GridComp/GEOSocean_GridComp/GuestOcean_GridComp/MOM6_GEOSPlug/@mom6
GEOSgcm_App            | src/Applications/@GEOSgcm_App
UMD_Etc                | src/Applications/@UMD_Etc
CPLFCST_Etc            | src/Applications/@CPLFCST_Etcpwd
/Users/mathomp4/MepoTalk/v10.16.3mepo-cd FMSpwd
/Users/mathomp4/MepoTalk/v10.16.3/src/Shared/@FMS

Running mepo-cd FMS is equivalent to cd $(mepo whereis FMS) (and indeed is run as such in the function).

Bare mepo-cd

In zsh and bash, running just mepo-cd will bring you back to the root of the fixture. It's equivalent to mepo-cd GEOSgcm say, for, the GEOSgcm fixture. Note though that due to limitation of csh/tcsh, this does not work there.

Bash

For bash, one should source the mepo-cd.bash script in the etc/ directory of mepo in their .bashrc:

[ -f /path/to/mepo/etc/mepo-cd.bash ] && source /path/to/mepo/etc/mepo-cd.bash

This adds a mepo-cd function to the shell.

NCCS

[ -f /discover/swdev/gmao_SIteam/mepo/etc/mepo-cd.bash ] && source /discover/swdev/gmao_SIteam/mepo/etc/mepo-cd.bash

NAS

[ -f /nobackup/gmao_SIteam/mepo/etc/mepo-cd.bash ] && source /nobackup/gmao_SIteam/mepo/etc/mepo-cd.bash

Zsh

For zsh, one should source the mepo-cd.zsh script in the etc/ directory of mepo in their .zshrc:

[[ -f /path/to/mepo/etc/mepo-cd.zsh ]] && source /path/to/mepo/etc/mepo-cd.zsh

This adds a mepo-cd function to the shell.

NCCS

[[ -f /discover/swdev/gmao_SIteam/mepo/etc/mepo-cd.zsh ]] && source /discover/swdev/gmao_SIteam/mepo/etc/mepo-cd.zsh

NAS

[[ -f /nobackup/gmao_SIteam/mepo/etc/mepo-cd.zsh ]] && source /nobackup/gmao_SIteam/mepo/etc/mepo-cd.zsh

csh/tcsh

For csh and tcsh, one would add to .cshrc or .tcshrc:

source /path/to/mepo/etc/mepo-cd.csh

Note that since csh and tcsh do not support shell functions, this defines an alias. It does not have as much power as the bash/zsh functions (for example, you cannot run mepo-cd by itself. It requires an argument.)

NCCS

source /discover/swdev/gmao_SIteam/mepo/etc/mepo-cd.csh

NAS

source /nobackup/gmao_SIteam/mepo/etc/mepo-cd.csh

mepo completion

A very limited bash completion script can be found in the mepo/etc/ folder as well. It is not very complete, but we would gladly accept any enhancements from users.

bash

[ -f /path/to/mepo/etc/mepo-completion.bash ] && source /path/to/mepo/etc/mepo-completion.bash

NCCS

[ -f /discover/swdev/gmao_SIteam/mepo/etc/mepo-completion.bash ] && source /discover/swdev/gmao_SIteam/mepo/etc/mepo-completion.bash

NAS

[ -f /nobackup/gmao_SIteam/mepo/etc/mepo-completion.bash ] && source /nobackup/gmao_SIteam/mepo/etc/mepo-completion.bash

zsh

[[ -f /path/to/mepo/etc/mepo-completion.bash ]] && source /path/to/mepo/etc/mepo-completion.bash

zsh users might have to add:

autoload -Uz bashcompinit && bashcompinit

before sourcing the bash completion script.

NCCS

[[ -f /discover/swdev/gmao_SIteam/mepo/etc/mepo-completion.bash ]] && source /discover/swdev/gmao_SIteam/mepo/etc/mepo-completion.bash

NAS

[[ -f /nobackup/gmao_SIteam/mepo/etc/mepo-completion.bash ]] && source /nobackup/gmao_SIteam/mepo/etc/mepo-completion.bash