Difference between revisions of "Tip/Foam version in shell prompt"

From OpenFOAMWiki
m (Correction)
m (Added setting for more modern zsh-configurations)
Line 12: Line 12:
 
</bash>
 
</bash>
 
in <tt>.zshrc.local</tt> will give you the same information (underlined)
 
in <tt>.zshrc.local</tt> will give you the same information (underlined)
 +
 +
If you use the more recent [http://grml.org/zsh/#grmlzshconfig configuration files from grml] then you have to add this information to the two standard-themes (setting PS1 won't work anymore):
 +
<bash>
 +
function openfoam_version_prompt () {
 +
    REPLY="%U(OF:$WM_PROJECT_VERSION-$WM_COMPILE_OPTION)%u "
 +
}
 +
grml_theme_add_token ofversion -f openfoam_version_prompt '%F{magenta}' '%f'
 +
 +
zstyle ':prompt:grml:left:setup' items rc ofversion change-root user at host path vcs percent
 +
zstyle ':prompt:grml-large:left:setup' items rc jobs history shell-level change-root time date newline ofversion user at host path vcs percent
 +
 +
# this is optional and generates a two-line prompt:
 +
prompt grml-large
 +
</bash>

Revision as of 08:55, 22 May 2013

If you're working with multiple OF-versions of OpenFOAM it can be useful if the used version of OpenFOAM is printed on the shell prompt (just like the current directory or other information you might have there).

Add

 
export PS1="(OF:\$WM_PROJECT_VERSION) $PS1"

to the end of your .bashrc and you'll have an output like (OF:1.9.x) on the left of your prompt (if the current shell uses OpenFOAM-1.9.x)

If you're a zsh-user then

 
export PS1="%U(OF:\$WM_PROJECT_VERSION)%u $PS1"

in .zshrc.local will give you the same information (underlined)

If you use the more recent configuration files from grml then you have to add this information to the two standard-themes (setting PS1 won't work anymore):

 
function openfoam_version_prompt () {
    REPLY="%U(OF:$WM_PROJECT_VERSION-$WM_COMPILE_OPTION)%u "
}
grml_theme_add_token ofversion -f openfoam_version_prompt '%F{magenta}' '%f'
 
zstyle ':prompt:grml:left:setup' items rc ofversion change-root user at host path vcs percent
zstyle ':prompt:grml-large:left:setup' items rc jobs history shell-level change-root time date newline ofversion user at host path vcs percent
 
# this is optional and generates a two-line prompt:
prompt grml-large