From 3a94826ed198ba9a569c77d163202707cda42530 Mon Sep 17 00:00:00 2001 From: LeMarsu Date: Mon, 15 Jan 2018 08:58:05 +0100 Subject: [PATCH 01/21] fix: Remove dependency of bc for load widget --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 97e99f43..14d7bd81 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -983,9 +983,9 @@ prompt_load() { # Replace comma load_avg=${load_avg//,/.} - if [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.7") ]]; then + 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" From afb7387abec505fb6565d31481c5f5ed724c2f08 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 2 Feb 2018 10:42:32 -0500 Subject: [PATCH 02/21] Documenting missing field from #716. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5fe57fd7..46d8ab61 100644 --- a/README.md +++ b/README.md @@ -585,6 +585,7 @@ customization is provided via: |`POWERLEVEL9K_VCS_GIT_HOOKS`|`(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)`|Layout of the segment for git repositories.| |`POWERLEVEL9K_VCS_HG_HOOKS`|`(vcs-detect-changes)`|Layout of the segment for Mercurial repositories.| |`POWERLEVEL9K_VCS_SVN_HOOKS`|`(vcs-detect-changes svn-detect-changes)`|Layout of the segment for SVN repositories.| +|`POWERLEVEL9K_VCS_ACTIONFORMAT_FOREGROUND`|`red`|The color of the foreground font during actions (e.g., `REBASE`).| ##### vcs symbols From 04850df7504326e06588bbbde4213137c9360e88 Mon Sep 17 00:00:00 2001 From: Daniel Tam Date: Sat, 3 Feb 2018 20:14:52 +1100 Subject: [PATCH 03/21] Add absolute truncation option to dir segment --- powerlevel9k.zsh-theme | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c32ccd48..4224075e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -728,6 +728,13 @@ prompt_dir() { set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026' case "$POWERLEVEL9K_SHORTEN_STRATEGY" in + truncate_absolute_chars) + if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then + current_path=$(echo $current_path | rev | cut -c 1-$POWERLEVEL9K_SHORTEN_DIR_LENGTH | rev | cat <(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) -) + fi + # Alternative implementation + #current_path="%$POWERLEVEL9K_SHORTEN_DIR_LENGTH<$POWERLEVEL9K_SHORTEN_DELIMITER<%~%<<" + ;; truncate_middle) current_path=$(echo "$current_path" | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g") ;; From c69d21016caa712481f3738a62ba2722d5583047 Mon Sep 17 00:00:00 2001 From: Matthew Hoener Date: Wed, 7 Feb 2018 14:56:48 -0800 Subject: [PATCH 04/21] Fix vi mode plugin --- powerlevel9k.zsh-theme | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14d7bd81..15a0b68a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1522,6 +1522,11 @@ NEWLINE=' [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]] && PROMPT="$NEWLINE$PROMPT" } +zle-keymap-select () { + zle reset-prompt + zle -R +} + prompt_powerlevel9k_setup() { # The value below was set to better support 32-bit CPUs. # It's the maximum _signed_ integer value on 32-bit CPUs. @@ -1590,6 +1595,8 @@ prompt_powerlevel9k_setup() { # prepare prompts add-zsh-hook precmd powerlevel9k_prepare_prompts add-zsh-hook preexec powerlevel9k_preexec + + zle -N zle-keymap-select } prompt_powerlevel9k_teardown() { From 162caba19cdc51ea52eb5fabd5d18f03cb20e467 Mon Sep 17 00:00:00 2001 From: Matthew Hoener Date: Wed, 7 Feb 2018 15:15:02 -0800 Subject: [PATCH 05/21] Don't show segment if POWERLEVEL9K_VI_INSERT_MODE_STRING == '' --- README.md | 2 ++ powerlevel9k.zsh-theme | 1 + 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 46d8ab61..fdb2f5d7 100644 --- a/README.md +++ b/README.md @@ -621,6 +621,8 @@ 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.| +To hide the segment entirely when in `INSERT` mode, set `POWERLEVEL9K_VI_INSERT_MODE_STRING=''` + #### Unit Test Ratios The `symfony2_tests` and `rspec_stats` segments both show a ratio of "real" diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 15a0b68a..6e30efee 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1366,6 +1366,7 @@ prompt_vi_mode() { "$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING" ;; main|viins|*) + if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi "$1_prompt_segment" "$0_INSERT" "$2" "$DEFAULT_COLOR" "blue" "$POWERLEVEL9K_VI_INSERT_MODE_STRING" ;; esac From d841e1d0d0bbc1260a12930d79402b93c57c828d Mon Sep 17 00:00:00 2001 From: Christo Kotze Date: Sat, 10 Feb 2018 13:29:04 +0400 Subject: [PATCH 06/21] Fix iTerm2 integration with PowerLevel9k This fix allows the user to see the "little blue triangle" that is created when iTerm2 shell integration is enabled. --- powerlevel9k.zsh-theme | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c32ccd48..c044c6b5 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1623,6 +1623,9 @@ $(print_icon 'MULTILINE_LAST_PROMPT_PREFIX')' NEWLINE=' ' [[ $POWERLEVEL9K_PROMPT_ADD_NEWLINE == true ]] && PROMPT="$NEWLINE$PROMPT" + + # Allow iTerm integration to work + [[ $ITERM_SHELL_INTEGRATION_INSTALLED == "Yes" ]] && PROMPT="%{$(iterm2_prompt_mark)%}$PROMPT" } set_default POWERLEVEL9K_IGNORE_TERM_COLORS false From 7b8656f8e79fb369b91b93cb3cbbe437935bb893 Mon Sep 17 00:00:00 2001 From: Michael Louwrens Date: Sat, 10 Feb 2018 19:46:31 +0200 Subject: [PATCH 07/21] add sudo status to context and user prompts --- powerlevel9k.zsh-theme | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c32ccd48..40b38a22 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -590,6 +590,7 @@ prompt_context() { typeset -AH context_states context_states=( "ROOT" "yellow" + "SUDO" "yellow" "DEFAULT" "yellow" "REMOTE" "yellow" ) @@ -608,6 +609,8 @@ prompt_context() { current_state="ROOT" elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then current_state="REMOTE" + elif sudo -n uptime >/dev/null 2>&1; then + current_statue="SUDO" fi "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" @@ -629,6 +632,14 @@ prompt_user() { "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "ROOT_ICON" ) + elif sudo -n uptime >/dev/null 2>&1; then + user_state=( + "STATE" "SUDO" + "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" + "BACKGROUND_COLOR" "${DEFAULT_COLOR}" + "FOREGROUND_COLOR" "yellow" + "VISUAL_IDENTIFIER" "ROOT_ICON" + ) else user_state=( "STATE" "DEFAULT" From 06802647a1919c8f51bbead78104a6093e137e5a Mon Sep 17 00:00:00 2001 From: Michael Louwrens Date: Sat, 10 Feb 2018 20:50:59 +0200 Subject: [PATCH 08/21] change sudo detection method --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 40b38a22..17af7ccb 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -609,7 +609,7 @@ prompt_context() { current_state="ROOT" elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then current_state="REMOTE" - elif sudo -n uptime >/dev/null 2>&1; then + elif sudo -n true 2>/dev/null; then current_statue="SUDO" fi @@ -632,7 +632,7 @@ prompt_user() { "FOREGROUND_COLOR" "yellow" "VISUAL_IDENTIFIER" "ROOT_ICON" ) - elif sudo -n uptime >/dev/null 2>&1; then + elif sudo -n true 2>/dev/null; then user_state=( "STATE" "SUDO" "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" From 0551854a9e09eb6b058710bb9af21327dfb13d54 Mon Sep 17 00:00:00 2001 From: Michael Louwrens Date: Sat, 10 Feb 2018 21:01:09 +0200 Subject: [PATCH 09/21] fix typo --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 17af7ccb..bce893fe 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -610,7 +610,7 @@ prompt_context() { elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then current_state="REMOTE" elif sudo -n true 2>/dev/null; then - current_statue="SUDO" + current_state="SUDO" fi "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" From 38937858736ff8a7483dbdd353c36aa190028aab Mon Sep 17 00:00:00 2001 From: Michael Louwrens Date: Sat, 10 Feb 2018 21:24:06 +0200 Subject: [PATCH 10/21] try out sudo icon changes --- functions/icons.zsh | 2 ++ powerlevel9k.zsh-theme | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index e642da00..b29d0108 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -258,6 +258,7 @@ case $POWERLEVEL9K_MODE in RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  CARRIAGE_RETURN_ICON $'\u21B5' # ↵ ROOT_ICON $'\uE614 ' #  + SUDO_ICON $'\uE0A2' #  RUBY_ICON $'\uF219 ' #  AWS_ICON $'\uF270' #  AWS_EB_ICON $'\UF1BD ' #  @@ -332,6 +333,7 @@ case $POWERLEVEL9K_MODE in RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  CARRIAGE_RETURN_ICON $'\u21B5' # ↵ ROOT_ICON $'\u26A1' # ⚡ + SUDO_ICON $'\uE0A2' #  RUBY_ICON '' AWS_ICON 'AWS:' AWS_EB_ICON $'\U1F331 ' # 🌱 diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bce893fe..2267ce64 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -638,7 +638,7 @@ prompt_user() { "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}" "BACKGROUND_COLOR" "${DEFAULT_COLOR}" "FOREGROUND_COLOR" "yellow" - "VISUAL_IDENTIFIER" "ROOT_ICON" + "VISUAL_IDENTIFIER" "SUDO_ICON" ) else user_state=( From 7fff5bd7a6c7c6d38c5984a1fa30571e89d14d1e Mon Sep 17 00:00:00 2001 From: Michael Louwrens Date: Mon, 12 Feb 2018 11:28:00 +0200 Subject: [PATCH 11/21] add new icons and add remote_sudo --- functions/icons.zsh | 5 ++++- powerlevel9k.zsh-theme | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index b29d0108..6000e108 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -27,6 +27,7 @@ case $POWERLEVEL9K_MODE in RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  CARRIAGE_RETURN_ICON $'\u21B5' # ↵ ROOT_ICON $'\uE801' #  + SUDO_ICON $'\uF09C' #  RUBY_ICON $'\uE847 ' #  AWS_ICON $'\uE895' #  AWS_EB_ICON $'\U1F331 ' # 🌱 @@ -105,6 +106,7 @@ case $POWERLEVEL9K_MODE in RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  CARRIAGE_RETURN_ICON $'\u21B5' # ↵ ROOT_ICON $'\uF201' #  + SUDO_ICON $'\uF09C' #  RUBY_ICON $'\uF219 ' #  AWS_ICON $'\uF270' #  AWS_EB_ICON $'\U1F331 ' # 🌱 @@ -188,6 +190,7 @@ case $POWERLEVEL9K_MODE in RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  CARRIAGE_RETURN_ICON $'\u21B5' # ↵ ROOT_ICON '\u'$CODEPOINT_OF_OCTICONS_ZAP #  + SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  RUBY_ICON '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  AWS_EB_ICON $'\U1F331 ' # 🌱 @@ -258,7 +261,7 @@ case $POWERLEVEL9K_MODE in RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' #  CARRIAGE_RETURN_ICON $'\u21B5' # ↵ ROOT_ICON $'\uE614 ' #  - SUDO_ICON $'\uE0A2' #  + SUDO_ICON $'\uF09C' #  RUBY_ICON $'\uF219 ' #  AWS_ICON $'\uF270' #  AWS_EB_ICON $'\UF1BD ' #  diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2267ce64..8eb13bde 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -589,10 +589,11 @@ prompt_context() { local current_state="DEFAULT" typeset -AH context_states context_states=( - "ROOT" "yellow" - "SUDO" "yellow" - "DEFAULT" "yellow" - "REMOTE" "yellow" + "ROOT" "yellow" + "SUDO" "yellow" + "DEFAULT" "yellow" + "REMOTE" "yellow" + "REMOTE_SUDO" "yellow" ) local content="" @@ -608,7 +609,11 @@ prompt_context() { if [[ $(print -P "%#") == '#' ]]; then current_state="ROOT" elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then - current_state="REMOTE" + if sudo -n true 2>/dev/null; then + current_state="REMOTE_SUDO" + else + current_state="REMOTE" + fi elif sudo -n true 2>/dev/null; then current_state="SUDO" fi From a4aacef7bc9663604682ab1afd5e76ef751d546e Mon Sep 17 00:00:00 2001 From: Michael Louwrens Date: Mon, 12 Feb 2018 11:39:53 +0200 Subject: [PATCH 12/21] Add information to readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 74edc446..4fb6614a 100644 --- a/README.md +++ b/README.md @@ -312,7 +312,7 @@ main theme distribution so that everyone can use it! The `context` segment (user@host string) is conditional. By default, it will only print if you are not your 'normal' user (including if you are root), or if -you are SSH'd to a remote host. +you are SSH'd to a remote host. `SUDO` and `REMOTE_SUDO` states are also available to show whether the current user or remote user has superuser privileges. To use this feature, make sure the `context` segment is enabled in your prompt elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`. @@ -580,6 +580,7 @@ You can also override the icons by setting: ``` POWERLEVEL9K_USER_ICON="\uF415" #  POWERLEVEL9K_ROOT_ICON="#" +POWERLEVEL9K_SUDO_ICON=$'\uF09C' #  ``` | Variable | Default Value | Description | From 3da37c0eaf1ae2e5949d205b3166cf4499c7d6d0 Mon Sep 17 00:00:00 2001 From: Daniel Tam Date: Mon, 12 Feb 2018 21:16:53 +1100 Subject: [PATCH 13/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 74edc446..81cd512d 100644 --- a/README.md +++ b/README.md @@ -375,6 +375,7 @@ Customizations available are: | Strategy Name | Description | |---------------|-------------| |Default|Truncate whole directories from left. How many is defined by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`| +|`truncate_absolute_chars`|Truncates an absolute number of characters from the left such that the number of characters that your path displays (including `POWERLEVEL9K_SHORTEN_DELIMITER`) is no more than `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.| |`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named `~/MySuperProjects/AwesomeFiles/BoringOffice`, then it will truncated to `~/MyS..cts/Awe..les/BoringOffice`, if `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).| |`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.| |`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| From eb1c6ec1fc6ac9310b815296dd791fe798ec74a8 Mon Sep 17 00:00:00 2001 From: Daniel Tam Date: Tue, 13 Feb 2018 22:18:26 +1100 Subject: [PATCH 14/21] Refactor absolute char truncation --- powerlevel9k.zsh-theme | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 4224075e..d66787c1 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -730,10 +730,8 @@ prompt_dir() { case "$POWERLEVEL9K_SHORTEN_STRATEGY" in truncate_absolute_chars) if [ ${#current_path} -gt $(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#POWERLEVEL9K_SHORTEN_DELIMITER} )) ]; then - current_path=$(echo $current_path | rev | cut -c 1-$POWERLEVEL9K_SHORTEN_DIR_LENGTH | rev | cat <(echo -n $POWERLEVEL9K_SHORTEN_DELIMITER) -) + current_path=$POWERLEVEL9K_SHORTEN_DELIMITER${current_path:(-POWERLEVEL9K_SHORTEN_DIR_LENGTH)} fi - # Alternative implementation - #current_path="%$POWERLEVEL9K_SHORTEN_DIR_LENGTH<$POWERLEVEL9K_SHORTEN_DELIMITER<%~%<<" ;; truncate_middle) current_path=$(echo "$current_path" | sed $SED_EXTENDED_REGEX_PARAMETER "s/([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})[^/]+([^/]{$POWERLEVEL9K_SHORTEN_DIR_LENGTH})\//\1$POWERLEVEL9K_SHORTEN_DELIMITER\2\//g") From d84420d950128025351febc4819ca5465b029fa1 Mon Sep 17 00:00:00 2001 From: Daniel Tam Date: Tue, 13 Feb 2018 22:21:15 +1100 Subject: [PATCH 15/21] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81cd512d..ff569d57 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,7 @@ Customizations available are: | Strategy Name | Description | |---------------|-------------| |Default|Truncate whole directories from left. How many is defined by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`| -|`truncate_absolute_chars`|Truncates an absolute number of characters from the left such that the number of characters that your path displays (including `POWERLEVEL9K_SHORTEN_DELIMITER`) is no more than `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.| +|`truncate_absolute_chars`|Truncates an absolute number of characters from the left such that the number of characters that your path displays (with or without `POWERLEVEL9K_SHORTEN_DELIMITER`) is no more than `POWERLEVEL9K_SHORTEN_DIR_LENGTH` + the length of `POWERLEVEL9K_SHORTEN_DELIMITER` | |`truncate_middle`|Truncates the middle part of a folder. E.g. you are in a folder named `~/MySuperProjects/AwesomeFiles/BoringOffice`, then it will truncated to `~/MyS..cts/Awe..les/BoringOffice`, if `POWERLEVEL9K_SHORTEN_DIR_LENGTH=3` is also set (controls the amount of characters to be left).| |`truncate_from_right`|Just leaves the beginning of a folder name untouched. E.g. your folders will be truncated like so: "/ro../Pr../office". How many characters will be untouched is controlled by `POWERLEVEL9K_SHORTEN_DIR_LENGTH`.| |`truncate_with_package_name`|Search for a `package.json` or `composer.json` and prints the `name` field to abbreviate the directory path. The precedence and/or files could be set by `POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)`. If you have [jq](https://stedolan.github.io/jq/) installed, it will dramatically improve the speed of this strategy.| From 845e74c5c3daff3f3d5a5f2a10edde279627c5b5 Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Fri, 16 Feb 2018 12:56:47 +0100 Subject: [PATCH 16/21] added LINUX_*_ICON for several OS --- functions/icons.zsh | 17 ++++++++++++++++- functions/utilities.zsh | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index e642da00..25546e77 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -151,7 +151,7 @@ case $POWERLEVEL9K_MODE in VCS_GIT_GITLAB_ICON $'\uF296 ' #  VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON '(svn) ' - RUST_ICON $'\uE6A8' #  + RUST_ICON $'\uE6A8' #  PYTHON_ICON $'\ue63c' #  SWIFT_ICON '' GO_ICON '' @@ -277,6 +277,21 @@ case $POWERLEVEL9K_MODE in WINDOWS_ICON $'\uF17A' #  FREEBSD_ICON $'\UF30E ' #  ANDROID_ICON $'\uF17B' #  + LINUX_ARCH_ICON $'\uF300' #  + LINUX_DEBIAN_ICON $'\uF302' #  + LINUX_UBUNTU_ICON $'\uF30C' #  + LINUX_CENTOS_ICON $'\uF301' #  + LINUX_COREOS_ICON $'\uF30F' #  + LINUX_ELEMENTARY_ICON $'\uF311' #  + LINUX_FEDORA_ICON $'\uF303' #  + LINUX_GENTOO_ICON $'\uF310' #  + LINUX_MINT_ICON $'\uF304' #  + LINUX_MAGEIA_ICON $'\uF306' #  + LINUX_MANDRIVA_ICON $'\uF307' #  + LINUX_OPENSUSE_ICON $'\uF308' #  + LINUX_REDHAT_ICON $'\uF309' #  + LINUX_SABAYON_ICON $'\uF313' #  + LINUX_SLACKWARE_ICON $'\uF30A' #  LINUX_ICON $'\uF17C' #  SUNOS_ICON $'\uF185 ' #  HOME_ICON $'\uF015' #  diff --git a/functions/utilities.zsh b/functions/utilities.zsh index b4bfb838..5f41f73e 100644 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -105,6 +105,22 @@ case $(uname) in OS='Linux' OS_ICON=$(print_icon 'LINUX_ICON') + # Check if the OS is debian + if [ `lsb_release -si`="Debian" ]; then + OS='Debian' + OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON') + fi + # Check if the OS is ubuntu + if [ `lsb_release -si`="Ubuntu" ]; then + OS='Ubuntu' + OS_ICON=$(print_icon 'LINUX_Ubuntu_ICON') + fi + # Check if the OS is mint + if [ `lsb_release -si`="Mint" ]; then + OS='Mint' + OS_ICON=$(print_icon 'LINUX_MINT_ICON') + fi + # Check if we're running on Android case $(uname -o 2>/dev/null) in Android) From bba8bb883e6990ebd4216c1fe025e9d0fa9121a3 Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Fri, 16 Feb 2018 16:45:09 +0100 Subject: [PATCH 17/21] add check of /etc/os-release for linux distros --- functions/colors.zsh | 0 functions/icons.zsh | 26 ++++++++-------- functions/utilities.zsh | 67 +++++++++++++++++++++++++++++++++-------- functions/vcs.zsh | 0 4 files changed, 66 insertions(+), 27 deletions(-) mode change 100644 => 100755 functions/colors.zsh mode change 100644 => 100755 functions/icons.zsh mode change 100644 => 100755 functions/utilities.zsh mode change 100644 => 100755 functions/vcs.zsh diff --git a/functions/colors.zsh b/functions/colors.zsh old mode 100644 new mode 100755 diff --git a/functions/icons.zsh b/functions/icons.zsh old mode 100644 new mode 100755 index 25546e77..5ae889e3 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -278,20 +278,18 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON $'\UF30E ' #  ANDROID_ICON $'\uF17B' #  LINUX_ARCH_ICON $'\uF300' #  - LINUX_DEBIAN_ICON $'\uF302' #  - LINUX_UBUNTU_ICON $'\uF30C' #  - LINUX_CENTOS_ICON $'\uF301' #  - LINUX_COREOS_ICON $'\uF30F' #  - LINUX_ELEMENTARY_ICON $'\uF311' #  - LINUX_FEDORA_ICON $'\uF303' #  - LINUX_GENTOO_ICON $'\uF310' #  - LINUX_MINT_ICON $'\uF304' #  - LINUX_MAGEIA_ICON $'\uF306' #  - LINUX_MANDRIVA_ICON $'\uF307' #  - LINUX_OPENSUSE_ICON $'\uF308' #  - LINUX_REDHAT_ICON $'\uF309' #  - LINUX_SABAYON_ICON $'\uF313' #  - LINUX_SLACKWARE_ICON $'\uF30A' #  + LINUX_DEBIAN_ICON $'\uF302' #  + LINUX_UBUNTU_ICON $'\uF30C' #  + LINUX_CENTOS_ICON $'\uF301' #  + LINUX_COREOS_ICON $'\uF30F' #  + LINUX_ELEMENTARY_ICON $'\uF311' #  + LINUX_FEDORA_ICON $'\uF303' #  + LINUX_GENTOO_ICON $'\uF310' #  + LINUX_MINT_ICON $'\uF304' #  + LINUX_MAGEIA_ICON $'\uF306' #  + LINUX_OPENSUSE_ICON $'\uF308' #  + LINUX_SABAYON_ICON $'\uF313' #  + LINUX_SLACKWARE_ICON $'\uF30A' #  LINUX_ICON $'\uF17C' #  SUNOS_ICON $'\uF185 ' #  HOME_ICON $'\uF015' #  diff --git a/functions/utilities.zsh b/functions/utilities.zsh old mode 100644 new mode 100755 index 5f41f73e..89020b09 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -102,24 +102,65 @@ case $(uname) in OS_ICON=$(print_icon 'FREEBSD_ICON') ;; Linux) - OS='Linux' - OS_ICON=$(print_icon 'LINUX_ICON') - - # Check if the OS is debian - if [ `lsb_release -si`="Debian" ]; then + os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" + case "$os_release_id" in + "arch") + OS='Arch' + OS_ICON=$(print_icon 'LINUX_ARCH_ICON') + ;; + "debian") OS='Debian' OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON') - fi - # Check if the OS is ubuntu - if [ `lsb_release -si`="Ubuntu" ]; then + ;; + "ubuntu") OS='Ubuntu' - OS_ICON=$(print_icon 'LINUX_Ubuntu_ICON') - fi - # Check if the OS is mint - if [ `lsb_release -si`="Mint" ]; then + OS_ICON=$(print_icon 'LINUX_UBUNTU_ICON') + ;; + "elementary") + OS='Elementary' + OS_ICON=$(print_icon 'LINUX_ELEMENTARY_ICON') + ;; + "fedora") + OS='Fedora' + OS_ICON=$(print_icon 'LINUX_FEDORA_ICON') + ;; + "coreos") + OS='CoreOS' + OS_ICON=$(print_icon 'LINUX_COREOS_ICON') + ;; + "gentoo") + OS='Gentoo' + OS_ICON=$(print_icon 'LINUX_GENTOO_ICON') + ;; + "mageia") + OS='Mageia' + OS_ICON=$(print_icon 'LINUX_MAGEIA_ICON') + ;; + "centos") + OS='CentOS' + OS_ICON=$(print_icon 'LINUX_CENTOS_ICON') + ;; + "opensuse"|"tumbleweed") + OS='OpenSUSE' + OS_ICON=$(print_icon 'LINUX_OPENSUSE_ICON') + ;; + "sabayon") + OS='Sabayon' + OS_ICON=$(print_icon 'LINUX_SABAYON_ICON') + ;; + "slackware") + OS='Slackware' + OS_ICON=$(print_icon 'LINUX_SLACKWARE_ICON') + ;; + "linuxmint") OS='Mint' OS_ICON=$(print_icon 'LINUX_MINT_ICON') - fi + ;; + *) + OS='Linux' + OS_ICON=$(print_icon 'LINUX_ICON') + ;; + esac # Check if we're running on Android case $(uname -o 2>/dev/null) in diff --git a/functions/vcs.zsh b/functions/vcs.zsh old mode 100644 new mode 100755 From 18ef14142a86564a73f6311e3e4307ae85968e15 Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Fri, 16 Feb 2018 17:31:17 +0100 Subject: [PATCH 18/21] add missing icons to compat set --- functions/icons.zsh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/functions/icons.zsh b/functions/icons.zsh index 5ae889e3..bf0bf9fc 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -365,6 +365,18 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON 'BSD' ANDROID_ICON 'And' LINUX_ICON 'Lx' + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' SUNOS_ICON 'Sun' HOME_ICON '' HOME_SUB_ICON '' From da9ec721b7e0a3fc7191d9b80e246a57bdfebf41 Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Fri, 16 Feb 2018 17:31:17 +0100 Subject: [PATCH 19/21] add missing icons to compat set --- functions/icons.zsh | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/functions/icons.zsh b/functions/icons.zsh index 5ae889e3..e89b3431 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -47,6 +47,18 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON $'\U1F608 ' # 😈 ANDROID_ICON $'\uE270' #  LINUX_ICON $'\uE271' #  + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' SUNOS_ICON $'\U1F31E ' # 🌞 HOME_ICON $'\uE12C' #  HOME_SUB_ICON $'\uE18D' #  @@ -125,6 +137,18 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON $'\U1F608 ' # 😈 ANDROID_ICON $'\uE17B' #  LINUX_ICON $'\uF17C' #  + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' SUNOS_ICON $'\uF185 ' #  HOME_ICON $'\uF015' #  HOME_SUB_ICON $'\uF07C' #  @@ -205,6 +229,18 @@ case $POWERLEVEL9K_MODE in APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE #  FREEBSD_ICON $'\U1F608 ' # 😈 LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  @@ -365,6 +401,18 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON 'BSD' ANDROID_ICON 'And' LINUX_ICON 'Lx' + LINUX_DEBIAN_ICON 'Deb' + LINUX_UBUNTU_ICON 'Ubu' + LINUX_CENTOS_ICON 'Cen' + LINUX_COREOS_ICON 'Cor' + LINUX_ELEMENTARY_ICON 'Elm' + LINUX_MINT_ICON 'LMi' + LINUX_FEDORA_ICON 'Fed' + LINUX_GENTOO_ICON 'Gen' + LINUX_MAGEIA_ICON 'Mag' + LINUX_OPENSUSE_ICON 'OSu' + LINUX_SABAYON_ICON 'Sab' + LINUX_SLACKWARE_ICON 'Sla' SUNOS_ICON 'Sun' HOME_ICON '' HOME_SUB_ICON '' From ba0e940af376fc4653c801bb85519032c8cf7697 Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Fri, 16 Feb 2018 17:42:14 +0100 Subject: [PATCH 20/21] arch icon was missing --- functions/icons.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/functions/icons.zsh b/functions/icons.zsh index e89b3431..c327b1e6 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -47,6 +47,7 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON $'\U1F608 ' # 😈 ANDROID_ICON $'\uE270' #  LINUX_ICON $'\uE271' #  + LINUX_ARCH_ICON 'Arc' LINUX_DEBIAN_ICON 'Deb' LINUX_UBUNTU_ICON 'Ubu' LINUX_CENTOS_ICON 'Cen' @@ -137,6 +138,7 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON $'\U1F608 ' # 😈 ANDROID_ICON $'\uE17B' #  LINUX_ICON $'\uF17C' #  + LINUX_ARCH_ICON 'Arc' LINUX_DEBIAN_ICON 'Deb' LINUX_UBUNTU_ICON 'Ubu' LINUX_CENTOS_ICON 'Cen' @@ -229,6 +231,7 @@ case $POWERLEVEL9K_MODE in APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE #  FREEBSD_ICON $'\U1F608 ' # 😈 LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  + LINUX_ARCH_ICON 'Arc' LINUX_DEBIAN_ICON 'Deb' LINUX_UBUNTU_ICON 'Ubu' LINUX_CENTOS_ICON 'Cen' @@ -401,6 +404,7 @@ case $POWERLEVEL9K_MODE in FREEBSD_ICON 'BSD' ANDROID_ICON 'And' LINUX_ICON 'Lx' + LINUX_ARCH_ICON 'Arc' LINUX_DEBIAN_ICON 'Deb' LINUX_UBUNTU_ICON 'Ubu' LINUX_CENTOS_ICON 'Cen' From 80176c263f0d4343a043e3284082299d9bfc5b8d Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Mon, 19 Feb 2018 18:48:21 +0100 Subject: [PATCH 21/21] fix $OS variable for battery segment --- functions/utilities.zsh | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 89020b09..1f4df9bc 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -102,58 +102,46 @@ case $(uname) in OS_ICON=$(print_icon 'FREEBSD_ICON') ;; Linux) + OS='Linux' os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" case "$os_release_id" in "arch") - OS='Arch' OS_ICON=$(print_icon 'LINUX_ARCH_ICON') ;; "debian") - OS='Debian' OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON') ;; "ubuntu") - OS='Ubuntu' OS_ICON=$(print_icon 'LINUX_UBUNTU_ICON') ;; "elementary") - OS='Elementary' OS_ICON=$(print_icon 'LINUX_ELEMENTARY_ICON') ;; "fedora") - OS='Fedora' OS_ICON=$(print_icon 'LINUX_FEDORA_ICON') ;; "coreos") - OS='CoreOS' OS_ICON=$(print_icon 'LINUX_COREOS_ICON') ;; "gentoo") - OS='Gentoo' OS_ICON=$(print_icon 'LINUX_GENTOO_ICON') ;; "mageia") - OS='Mageia' OS_ICON=$(print_icon 'LINUX_MAGEIA_ICON') ;; "centos") - OS='CentOS' OS_ICON=$(print_icon 'LINUX_CENTOS_ICON') ;; "opensuse"|"tumbleweed") - OS='OpenSUSE' OS_ICON=$(print_icon 'LINUX_OPENSUSE_ICON') ;; "sabayon") - OS='Sabayon' OS_ICON=$(print_icon 'LINUX_SABAYON_ICON') ;; "slackware") - OS='Slackware' OS_ICON=$(print_icon 'LINUX_SLACKWARE_ICON') ;; "linuxmint") - OS='Mint' OS_ICON=$(print_icon 'LINUX_MINT_ICON') ;; *)