mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +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)
|
||||
|
||||
### `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
|
||||
|
||||
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:
|
||||
|
||||
* [aws](#aws) - The current AWS profile, if active.
|
||||
* **background_jobs** - INdicator for background jobs.
|
||||
* [battery](#battery) - Current battery status.
|
||||
* [context](#context) - Your username and host.
|
||||
* [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.
|
||||
* [ram](#ram) - Show free RAM and used Swap.
|
||||
* [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.
|
||||
* **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_version** - Show the current Symfony2 version, if you are in a Symfony2-Project dir.
|
||||
* [time](#time) - System time.
|
||||
|
@ -222,10 +224,9 @@ See [Unit Test Ratios](#unit-test-ratios), below.
|
|||
|
||||
##### status
|
||||
|
||||
This segment shows the return code of the last command, and the presence of any
|
||||
background jobs. By default, this segment will always print, but you can
|
||||
customize it to only print if there is an error or a forked job by setting the
|
||||
following variable in your `~/.zshrc`.
|
||||
This segment shows the return code of the last command. By default, this
|
||||
segment will always print, but you can customize it to only print if there
|
||||
is an error by setting the following variable in your `~/.zshrc`.
|
||||
|
||||
POWERLEVEL9K_STATUS_VERBOSE=false
|
||||
|
||||
|
|
|
@ -238,6 +238,13 @@ prompt_custom() {
|
|||
"$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() {
|
||||
# The battery can have different states.
|
||||
# Default is "unknown"
|
||||
|
@ -537,6 +544,13 @@ prompt_rbenv() {
|
|||
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
|
||||
prompt_rust_version() {
|
||||
local rust_version
|
||||
|
@ -572,26 +586,17 @@ prompt_rvm() {
|
|||
# Status: (return code, root status, background jobs)
|
||||
set_default POWERLEVEL9K_STATUS_VERBOSE true
|
||||
prompt_status() {
|
||||
local symbols bg
|
||||
symbols=()
|
||||
|
||||
if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
|
||||
if [[ "$RETVAL" -ne 0 ]]; then
|
||||
symbols+="%F{226}$RETVAL $(print_icon 'CARRIAGE_RETURN_ICON')%f"
|
||||
bg="red"
|
||||
"$1_prompt_segment" "$0_ERROR" "red" "226" "$RETVAL $(print_icon 'CARRIAGE_RETURN_ICON')"
|
||||
else
|
||||
symbols+="%F{046}$(print_icon 'OK_ICON')%f"
|
||||
bg="black"
|
||||
"$1_prompt_segment" "$0_OK" "$DEFAULT_COLOR" "046" "$(print_icon 'OK_ICON')"
|
||||
fi
|
||||
else
|
||||
[[ "$RETVAL" -ne 0 ]] && symbols+="%{%F{red}%}$(print_icon 'FAIL_ICON')%f"
|
||||
bg="$DEFAULT_COLOR"
|
||||
if [[ "$RETVAL" -ne 0 ]]; then
|
||||
"$1_prompt_segment" "$0_ERROR" "$DEFAULT_COLOR" "red" "$(print_icon 'FAIL_ICON')"
|
||||
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
|
||||
|
@ -753,7 +758,7 @@ build_left_prompt() {
|
|||
|
||||
# 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
|
||||
# Check if it is a custom command, otherwise interpet it as
|
||||
|
|
Loading…
Reference in a new issue