aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md26
-rw-r--r--functions/icons.zsh16
-rwxr-xr-xpowerlevel9k.zsh-theme51
3 files changed, 84 insertions, 9 deletions
diff --git a/README.md b/README.md
index caeeccbb..ef9c8c88 100644
--- a/README.md
+++ b/README.md
@@ -143,6 +143,7 @@ The segments that are currently available are:
* [`command_execution_time`](#command_execution_time) - Display the time the current command took to execute.
* [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file.
* `detect_virt` - Virtualization detection with systemd
+* `newline` - Continues the prompt on a new line.
---------------------------------------------------------------------------------
@@ -442,6 +443,15 @@ segment will not be displayed.
|`POWERLEVEL9K_PUBLIC_IP_METHODS`|(dig curl wget)| These methods in that order are used to refresh your IP.|
|`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained|
+##### newline
+
+Puts a newline in your prompt so you can continue using segments on the next
+line. This allows you to use segments on both lines, unlike
+`POWERLEVEL9K_PROMPT_ON_NEWLINE`, which simply separates segments from the
+prompt itself.
+
+This only works on the left side. On the right side it does nothing.
+
##### rbenv
This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack.
@@ -463,6 +473,7 @@ This segment shows the return code of the last command.
|----------|---------------|-------------|
|`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to not show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE` to false.|
|`POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE`|`false`|Set to true if you wish to show this segment when the last command completed successfully in non-verbose mode.|
+|`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.|
##### ram
@@ -547,6 +558,21 @@ is count your source files and test files, and calculate the ratio between them.
Just enough to give you a quick overview about the test situation of the project
you are dealing with.
+### Disabling / Enabling Powerlevel9k
+
+You can disable P9k and return to a very basic prompt at any time simply by
+calling:
+
+```zsh
+$ prompt_powerlevel9k_teardown
+```
+
+You can then re-enable it by calling:
+
+```zsh
+$ prompt_powerlevel9k_setup
+```
+
### tl; dr
Want to just get a quick start? Check out the [Show Off Your
diff --git a/functions/icons.zsh b/functions/icons.zsh
index 7b3bba78..238b6b9e 100644
--- a/functions/icons.zsh
+++ b/functions/icons.zsh
@@ -39,8 +39,9 @@ case $POWERLEVEL9K_MODE in
FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF'
NODE_ICON $'\u2B22' # ⬢
- MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500'
- MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 '
+ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
+ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─
+ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON $'\uE26E' # 
WINDOWS_ICON $'\uE26F' # 
FREEBSD_ICON $'\U1F608 ' # 😈
@@ -111,7 +112,8 @@ case $POWERLEVEL9K_MODE in
SYMFONY_ICON 'SF'
NODE_ICON $'\u2B22' # ⬢
MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
- MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
+ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─
+ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON $'\uF179' # 
WINDOWS_ICON $'\uF17A' # 
FREEBSD_ICON $'\U1F608 ' # 😈
@@ -178,7 +180,8 @@ case $POWERLEVEL9K_MODE in
SYMFONY_ICON $'\uE757' # 
NODE_ICON $'\uE617 ' # 
MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
- MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
+ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─
+ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON $'\uF179' # 
WINDOWS_ICON $'\uF17A' # 
FREEBSD_ICON $'\UF30E ' # 
@@ -244,8 +247,9 @@ case $POWERLEVEL9K_MODE in
FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF'
NODE_ICON $'\u2B22' # ⬢
- MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\u2500'
- MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 '
+ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
+ MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─
+ MULTILINE_LAST_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
APPLE_ICON 'OSX'
WINDOWS_ICON 'WIN'
FREEBSD_ICON 'BSD'
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index d99b6e38..2f2a682d 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -337,6 +337,23 @@ prompt_background_jobs() {
fi
}
+# A newline in your prompt, so you can segments on multiple lines.
+prompt_newline() {
+ local lws newline
+ [[ "$1" == "right" ]] && return
+ newline=$'\n'
+ lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS
+ if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then
+ newline="${newline}$(print_icon 'MULTILINE_NEWLINE_PROMPT_PREFIX')"
+ fi
+ POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=
+ "$1_prompt_segment" \
+ "$0" \
+ "$2" \
+ "NONE" "NONE" "${newline}"
+ POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws
+}
+
# Segment that indicates usage level of current partition.
set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false
set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90
@@ -1022,10 +1039,30 @@ prompt_ssh() {
# Status: return code if verbose, otherwise just an icon if an error occurred
set_default POWERLEVEL9K_STATUS_VERBOSE true
set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false
+set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true
prompt_status() {
- if [[ "$RETVAL" -ne 0 ]]; then
+ local ec_text
+ local ec_sum
+ local ec
+
+ if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then
+ ec_text=${RETVALS[1]}
+ ec_sum=${RETVALS[1]}
+
+ for ec in "${(@)RETVALS[2,-1]}"; do
+ ec_text="${ec_text}|${ec}"
+ ec_sum=$(( $ec_sum + $ec ))
+ done
+ else
+ # We use RETVAL instead of the right-most RETVALS item because
+ # PIPE_FAIL may be set.
+ ec_text=${RETVAL}
+ ec_sum=${RETVAL}
+ fi
+
+ if (( ec_sum > 0 )); then
if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
- "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$RETVAL" 'CARRIAGE_RETURN_ICON'
+ "$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$ec_text" 'CARRIAGE_RETURN_ICON'
else
"$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON'
fi
@@ -1309,6 +1346,7 @@ powerlevel9k_preexec() {
set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false
powerlevel9k_prepare_prompts() {
RETVAL=$?
+ RETVALS=( "$pipestatus[@]" )
_P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START))
@@ -1317,7 +1355,7 @@ powerlevel9k_prepare_prompts() {
if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then
PROMPT='$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt)
-$(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')'
+$(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')'
if [[ "$POWERLEVEL9K_RPROMPT_ON_NEWLINE" != true ]]; then
# The right prompt should be on the same line as the first line of the left
# prompt. To do so, there is just a quite ugly workaround: Before zsh draws
@@ -1415,4 +1453,11 @@ prompt_powerlevel9k_setup() {
add-zsh-hook preexec powerlevel9k_preexec
}
+prompt_powerlevel9k_teardown() {
+ add-zsh-hook -D precmd powerlevel9k_\*
+ add-zsh-hook -D preexec powerlevel9k_\*
+ PROMPT='%m%# '
+ RPROMPT=
+}
+
prompt_powerlevel9k_setup "$@"