mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
add nodeenv-prompt plugin
This commit is contained in:
parent
a38af27991
commit
44968b0b9a
2 changed files with 53 additions and 0 deletions
35
plugins/nodeenv-prompt/README.md
Normal file
35
plugins/nodeenv-prompt/README.md
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
oh-my-zsh::plugin::nodeenv-prompt
|
||||||
|
====================================
|
||||||
|
|
||||||
|
This is a plugin derived from
|
||||||
|
[virtualenv prompt](https://github.com/tonyseek/oh-my-zsh-virtualenv-prompt).
|
||||||
|
It support to customize the
|
||||||
|
[nodeenv](https://github.com/ekalinin/nodeenv)
|
||||||
|
prompt in oh-my-zsh themes.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
You can install this plugin from shell:
|
||||||
|
|
||||||
|
repo="git://github.com/chenhouwu/oh-my-zsh-nodeenv-prompt.git"
|
||||||
|
target="$HOME/.oh-my-zsh/custom/plugins/nodeenv-prompt"
|
||||||
|
|
||||||
|
git clone $repo $target
|
||||||
|
|
||||||
|
|
||||||
|
Customize Theme
|
||||||
|
---------------
|
||||||
|
|
||||||
|
There are two constant strings which could be overrided in your custom theme.
|
||||||
|
|
||||||
|
- `ZSH_THEME_NODEENV_PROMPT_PREFIX`
|
||||||
|
- `ZSH_THEME_NODEENV_PROMPT_SUFFIX`
|
||||||
|
|
||||||
|
And the function `nodeenv_prompt_info` could be used in the prompt of your
|
||||||
|
theme.
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
See the [oh-my-zsh::theme::seeker](https://github.com/tonyseek/oh-my-zsh-seeker-theme).
|
||||||
18
plugins/nodeenv-prompt/nodeenv-prompt.plugin.zsh
Normal file
18
plugins/nodeenv-prompt/nodeenv-prompt.plugin.zsh
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
export NODE_VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
|
|
||||||
|
ZSH_THEME_NODEENV_PROMPT_PREFIX="("
|
||||||
|
ZSH_THEME_NODEENV_PROMPT_SUFFIX=")"
|
||||||
|
|
||||||
|
function nodeenv_prompt_info() {
|
||||||
|
if [ -n "$NODE_VIRTUAL_ENV" ]; then
|
||||||
|
|
||||||
|
if [ "`basename "$NODE_VIRTUAL_ENV"`" = "__" ] ; then
|
||||||
|
# special case for Aspen magic directories
|
||||||
|
# see http://www.zetadev.com/software/aspen/
|
||||||
|
local name="[`basename \`dirname "$NODE_VIRTUAL_ENV"\``]"
|
||||||
|
else
|
||||||
|
local name=`basename "$NODE_VIRTUAL_ENV"`
|
||||||
|
fi
|
||||||
|
echo "$ZSH_THEME_NODEENV_PROMPT_PREFIX$name$ZSH_THEME_NODEENV_PROMPT_SUFFIX"
|
||||||
|
fi
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue