Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ The segments that are currently available are:
* **GoLang Segments:**
* `go_version` - Show the current GO version.
* **Javascript / Node.js Segments:**
* `node_version` - Show the version number of the installed Node.js.
* [`node_version`](#node_version) - Show the version number of the installed Node.js.
* `nodeenv` - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name.
* `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM
* **PHP Segments:**
Expand Down Expand Up @@ -638,6 +638,15 @@ you are using the [ZSH Line Editor](http://zsh.sourceforge.net/Doc/Release/Zsh-L
|`POWERLEVEL9K_VI_INSERT_MODE_STRING`|`"INSERT"`|String to display while in 'Insert' mode.|
|`POWERLEVEL9K_VI_COMMAND_MODE_STRING`|`"NORMAL"`|String to display while in 'Command' mode.|

##### node_version

This segment shows the _NodeJS_ version, that is currently active.

| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY`|`false`|If `true` this segment only appears inside _NodeJS_ projects described by a `package.json`.|


#### Unit Test Ratios

The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real"
Expand Down
38 changes: 31 additions & 7 deletions powerlevel9k.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,9 @@ prompt_load() {
# Replace comma
load_avg=${load_avg//,/.}

if [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.7") ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are changes to prompt_load so muddies your PR. Would it be possible to do this in a separate PR if you want to suggest these changes, and also document what the changes are and why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That have to be a slip. Wasn't my intention to touch this. I will revert this immediately.

if [[ "$load_avg" -gt $((${cores} * 0.7)) ]]; then
current_state="critical"
elif [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.5") ]]; then
elif [[ "$load_avg" -gt $((${cores} * 0.5)) ]]; then
current_state="warning"
else
current_state="normal"
Expand All @@ -1034,13 +1034,37 @@ prompt_load() {
"$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg" 'LOAD_ICON'
}

################################################################
# Segment to diplay Node version
# Node version
set_default POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=false

prompt_node_version() {
local node_version=$(node -v 2>/dev/null)
[[ -z "${node_version}" ]] && return
if [ "$POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY" = true ] ; then
local foundProject=false # Variable to stop searching if a project has been found.
local currentDir=$(pwd) # Variable to iterate trough the path reverse.

# Search as long as no project could been found or the root directory has been reached.
while [ "$foundProject" = false -a ! "$currentDir" = "/" ] ; do
# Check if directory contain a project description.
if [[ -a "$currentDir/package.json" ]] ; then
foundProject=true
fi

"$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON'
# Go to the parent directory.
currentDir="$(dirname "$currentDir")"
done
fi

# Show version if it should been shown always or if a project has been found.
if [ "$POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY" = false -o "$foundProject" = true ] ; then
# Get the node version.
local node_version=$(node -v 2>/dev/null)

# Return if node is not installed (version output empty).
[[ -z "${node_version}" ]] && return

# Define the segments itself.
"$1_prompt_segment" "$0" "$2" "green" "white" "${node_version:1}" 'NODE_ICON'
fi
}

################################################################
Expand Down