mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-29 14:50:08 +00:00
Split up the status
segment into a background_jobs
, root_indicator
and status
segment.
This fixes #163
This commit is contained in:
parent
0059f9a066
commit
5a4de1d274
3 changed files with 32 additions and 20 deletions
|
@ -1,5 +1,11 @@
|
||||||
## v0.3.0 (next)
|
## v0.3.0 (next)
|
||||||
|
|
||||||
|
### `status` changes
|
||||||
|
|
||||||
|
The `status` segment was split up into three segments. `background_jobs` prints
|
||||||
|
an icon if there are background jobs. `root_indicator` prints an icon if the user
|
||||||
|
is root. The `status` segment focuses now on the status only.
|
||||||
|
|
||||||
### New segment `custom_command` added
|
### New segment `custom_command` added
|
||||||
|
|
||||||
A new segment that allows users to define a custom command was added.
|
A new segment that allows users to define a custom command was added.
|
||||||
|
|
11
README.md
11
README.md
|
@ -71,6 +71,7 @@ configuration is the default:
|
||||||
The segments that are currently available are:
|
The segments that are currently available are:
|
||||||
|
|
||||||
* [aws](#aws) - The current AWS profile, if active.
|
* [aws](#aws) - The current AWS profile, if active.
|
||||||
|
* **background_jobs** - INdicator for background jobs.
|
||||||
* [battery](#battery) - Current battery status.
|
* [battery](#battery) - Current battery status.
|
||||||
* [context](#context) - Your username and host.
|
* [context](#context) - Your username and host.
|
||||||
* [custom_command](#custom_command) - A custom command to display the output of.
|
* [custom_command](#custom_command) - A custom command to display the output of.
|
||||||
|
@ -85,9 +86,10 @@ The segments that are currently available are:
|
||||||
* **php_version** - Show the current PHP version.
|
* **php_version** - Show the current PHP version.
|
||||||
* [ram](#ram) - Show free RAM and used Swap.
|
* [ram](#ram) - Show free RAM and used Swap.
|
||||||
* [rbenv](#rbenv) - Ruby environment information (if one is active).
|
* [rbenv](#rbenv) - Ruby environment information (if one is active).
|
||||||
|
* **root_indicator** - An indicator if the user is root.
|
||||||
* [rspec_stats](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec.
|
* [rspec_stats](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec.
|
||||||
* **rust_version** - Display the current rust version.
|
* **rust_version** - Display the current rust version.
|
||||||
* [status](#status) - The return code of the previous command, and status of background jobs.
|
* [status](#status) - The return code of the previous command.
|
||||||
* [symphony2_tests](#symphony2_tests) - Show a ratio of test classes vs code classes for Symfony2.
|
* [symphony2_tests](#symphony2_tests) - Show a ratio of test classes vs code classes for Symfony2.
|
||||||
* **symphony2_version** - Show the current Symfony2 version, if you are in a Symfony2-Project dir.
|
* **symphony2_version** - Show the current Symfony2 version, if you are in a Symfony2-Project dir.
|
||||||
* [time](#time) - System time.
|
* [time](#time) - System time.
|
||||||
|
@ -222,10 +224,9 @@ See [Unit Test Ratios](#unit-test-ratios), below.
|
||||||
|
|
||||||
##### status
|
##### status
|
||||||
|
|
||||||
This segment shows the return code of the last command, and the presence of any
|
This segment shows the return code of the last command. By default, this
|
||||||
background jobs. By default, this segment will always print, but you can
|
segment will always print, but you can customize it to only print if there
|
||||||
customize it to only print if there is an error or a forked job by setting the
|
is an error by setting the following variable in your `~/.zshrc`.
|
||||||
following variable in your `~/.zshrc`.
|
|
||||||
|
|
||||||
POWERLEVEL9K_STATUS_VERBOSE=false
|
POWERLEVEL9K_STATUS_VERBOSE=false
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,13 @@ prompt_custom() {
|
||||||
"$1_prompt_segment" "${0}_${2:u}" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})"
|
"$1_prompt_segment" "${0}_${2:u}" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$(eval ${(P)command})"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# print an icon, if there are background jobs
|
||||||
|
prompt_background_jobs() {
|
||||||
|
if [[ $(jobs -l | wc -l) -gt 0 ]]; then
|
||||||
|
"$1_prompt_segment" "$0" "$DEFAULT_COLOR" "cyan" "$(print_icon 'BACKGROUND_JOBS_ICON')"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
prompt_battery() {
|
prompt_battery() {
|
||||||
# The battery can have different states.
|
# The battery can have different states.
|
||||||
# Default is "unknown"
|
# Default is "unknown"
|
||||||
|
@ -537,6 +544,13 @@ prompt_rbenv() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# print an icon if user is root.
|
||||||
|
prompt_root_indicator() {
|
||||||
|
if [[ "$UID" -eq 0 ]]; then
|
||||||
|
"$1_prompt_segment" "$0" "$DEFAULT_COLOR" "yellow" "$(print_icon 'ROOT_ICON')"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# print Rust version number
|
# print Rust version number
|
||||||
prompt_rust_version() {
|
prompt_rust_version() {
|
||||||
local rust_version
|
local rust_version
|
||||||
|
@ -572,26 +586,17 @@ prompt_rvm() {
|
||||||
# Status: (return code, root status, background jobs)
|
# Status: (return code, root status, background jobs)
|
||||||
set_default POWERLEVEL9K_STATUS_VERBOSE true
|
set_default POWERLEVEL9K_STATUS_VERBOSE true
|
||||||
prompt_status() {
|
prompt_status() {
|
||||||
local symbols bg
|
|
||||||
symbols=()
|
|
||||||
|
|
||||||
if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
|
if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
|
||||||
if [[ "$RETVAL" -ne 0 ]]; then
|
if [[ "$RETVAL" -ne 0 ]]; then
|
||||||
symbols+="%F{226}$RETVAL $(print_icon 'CARRIAGE_RETURN_ICON')%f"
|
"$1_prompt_segment" "$0_ERROR" "red" "226" "$RETVAL $(print_icon 'CARRIAGE_RETURN_ICON')"
|
||||||
bg="red"
|
|
||||||
else
|
else
|
||||||
symbols+="%F{046}$(print_icon 'OK_ICON')%f"
|
"$1_prompt_segment" "$0_OK" "$DEFAULT_COLOR" "046" "$(print_icon 'OK_ICON')"
|
||||||
bg="black"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
[[ "$RETVAL" -ne 0 ]] && symbols+="%{%F{red}%}$(print_icon 'FAIL_ICON')%f"
|
if [[ "$RETVAL" -ne 0 ]]; then
|
||||||
bg="$DEFAULT_COLOR"
|
"$1_prompt_segment" "$0_ERROR" "$DEFAULT_COLOR" "red" "$(print_icon 'FAIL_ICON')"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "$UID" -eq 0 ]] && symbols+="%{%F{yellow}%} $(print_icon 'ROOT_ICON')%f"
|
|
||||||
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$(print_icon 'BACKGROUND_JOBS_ICON')%f"
|
|
||||||
|
|
||||||
[[ -n "$symbols" ]] && "$1_prompt_segment" "$0" "$bg" "white" "$symbols"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Symfony2-PHPUnit test ratio
|
# Symfony2-PHPUnit test ratio
|
||||||
|
@ -753,7 +758,7 @@ build_left_prompt() {
|
||||||
|
|
||||||
# Right prompt
|
# Right prompt
|
||||||
build_right_prompt() {
|
build_right_prompt() {
|
||||||
defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time)
|
defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs root_indicator history time)
|
||||||
|
|
||||||
for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do
|
for element in "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]}"; do
|
||||||
# Check if it is a custom command, otherwise interpet it as
|
# Check if it is a custom command, otherwise interpet it as
|
||||||
|
|
Loading…
Reference in a new issue