From 1619c74ad8aff47383989efadc1e4553a83cf4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Thu, 4 May 2017 02:32:18 -0400 Subject: [PATCH 1/3] newline: add new segment --- README.md | 8 ++++++++ powerlevel9k.zsh-theme | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index caeeccbb..b52edeb7 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,13 @@ 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` and +`POWERLEVEL9K_RPROMPT_ON_NEWLINE`. + ##### rbenv This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2d664911..83c5966e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -337,6 +337,21 @@ prompt_background_jobs() { fi } +# A newline in your prompt, so you can segments on multiple lines. +prompt_newline() { + local lws rws + lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS + rws=$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= + POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS= + "$1_prompt_segment" \ + "$0" \ + "$2" \ + "NONE" "NONE" $'\n' + POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws + POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=$rws +} + # Segment that indicates usage level of current partition. set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 From 161c995625fc655eb3228a88f5ce1ad79fd1ede0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Thu, 4 May 2017 02:44:37 -0400 Subject: [PATCH 2/3] newline: can't work with right side --- README.md | 5 +++-- powerlevel9k.zsh-theme | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b52edeb7..bc9b4462 100644 --- a/README.md +++ b/README.md @@ -447,8 +447,9 @@ segment will not be displayed. 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` and -`POWERLEVEL9K_RPROMPT_ON_NEWLINE`. +This allows you to use segments on both lines, unlike `POWERLEVEL9K_PROMPT_ON_NEWLINE`. + +This only works on the left side. On the right side it does nothing. ##### rbenv diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 83c5966e..bcce12f4 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -339,17 +339,15 @@ prompt_background_jobs() { # A newline in your prompt, so you can segments on multiple lines. prompt_newline() { - local lws rws + local lws + [[ "$1" == "right" ]] && return lws=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS - rws=$POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS= - POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS= "$1_prompt_segment" \ "$0" \ "$2" \ "NONE" "NONE" $'\n' POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws - POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS=$rws } # Segment that indicates usage level of current partition. From e9e3e9dc538edc82bf8071919eca2fc9c56292a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Fri, 12 May 2017 21:07:50 -0400 Subject: [PATCH 3/3] newline: support PROMPT_ON_NEWLINE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The newline segment will now show ├─ when using `POWERLEVEL9K_PROMPT_ON_NEWLINE` Note: This can be overridden via `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX` --- functions/icons.zsh | 12 ++++++++---- powerlevel9k.zsh-theme | 8 ++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 7b3bba78..72e0fbe4 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_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uE26E' #  WINDOWS_ICON $'\uE26F' #  FREEBSD_ICON $'\U1F608 ' # 😈 @@ -111,6 +112,7 @@ case $POWERLEVEL9K_MODE in SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  WINDOWS_ICON $'\uF17A' #  @@ -178,6 +180,7 @@ case $POWERLEVEL9K_MODE in SYMFONY_ICON $'\uE757' #  NODE_ICON $'\uE617 ' #  MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ + MULTILINE_NEWLINE_PROMPT_PREFIX $'\u251C'$'\U2500' # ├─ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON $'\uF179' #  WINDOWS_ICON $'\uF17A' #  @@ -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_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─ APPLE_ICON 'OSX' WINDOWS_ICON 'WIN' FREEBSD_ICON 'BSD' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bcce12f4..cad455e6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -339,14 +339,18 @@ prompt_background_jobs() { # A newline in your prompt, so you can segments on multiple lines. prompt_newline() { - local lws + 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" $'\n' + "NONE" "NONE" "${newline}" POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS=$lws }