From 4bee6dc93db4ca411ac267431c9777cbc72eb60f Mon Sep 17 00:00:00 2001 From: Dean Fenster Date: Sat, 3 Dec 2016 19:46:25 +0200 Subject: [PATCH 01/59] Fixed an issue where full battery registers as disconnected --- powerlevel9k.zsh-theme | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c06d1286..8ada453d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -397,11 +397,12 @@ prompt_battery() { # Return if no battery found [[ -z $bat ]] && return - - [[ $(cat $bat/capacity) -gt 100 ]] && local bat_percent=100 || local bat_percent=$(cat $bat/capacity) - [[ $(cat $bat/status) =~ Charging ]] && local connected=true - [[ $(cat $bat/status) =~ Charging && $bat_percent =~ 100 ]] && current_state="charged" - [[ $(cat $bat/status) =~ Charging && $bat_percent -lt 100 ]] && current_state="charging" + local capacity=$(cat $bat/capacity) + local battery_status=$(cat $bat/status) + [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity + [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true + [[ $connected && $bat_percent =~ 100 ]] && current_state="charged" + [[ $connected && $bat_percent -lt 100 ]] && current_state="charging" if [[ -z $connected ]]; then [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" fi From a637321d58935d4dc4ee25e97c7a2ee02f7c8387 Mon Sep 17 00:00:00 2001 From: Dean Fenster Date: Sat, 3 Dec 2016 20:02:52 +0200 Subject: [PATCH 02/59] Fixed syntax issue --- powerlevel9k.zsh-theme | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8ada453d..c21d0b43 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -401,10 +401,11 @@ prompt_battery() { local battery_status=$(cat $bat/status) [[ $capacity -gt 100 ]] && local bat_percent=100 || local bat_percent=$capacity [[ $battery_status =~ Charging || $battery_status =~ Full ]] && local connected=true - [[ $connected && $bat_percent =~ 100 ]] && current_state="charged" - [[ $connected && $bat_percent -lt 100 ]] && current_state="charging" if [[ -z $connected ]]; then [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" + else + [[ $bat_percent =~ 100 ]] && current_state="charged" + [[ $bat_percent -lt 100 ]] && current_state="charging" fi if [[ -f /usr/bin/acpi ]]; then local time_remaining=$(acpi | awk '{ print $5 }') From b37090073c5ad491d7f70803e7f06168471b3148 Mon Sep 17 00:00:00 2001 From: Dean Fenster Date: Thu, 8 Dec 2016 21:06:07 +0200 Subject: [PATCH 03/59] Supressed error message for invalid acpi date (happens when disconnecting the power cable) --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c21d0b43..d56e46f4 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -412,7 +412,7 @@ prompt_battery() { if [[ $time_remaining =~ rate ]]; then local tstring="..." elif [[ $time_remaining =~ "[:digit:]+" ]]; then - local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M)} + local tstring=${(f)$(date -u -d "$(echo $time_remaining)" +%k:%M 2> /dev/null)} fi fi [[ -n $tstring ]] && local remain=" ($tstring)" From 81f7175f768d5fa653003a3cf09dd04cee0f4fb4 Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:05:23 +0100 Subject: [PATCH 04/59] Add service icon definition for fa-patched Add configuration for icon definitions on 'flat'|'awesome-patched' section. --- functions/icons.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/icons.zsh b/functions/icons.zsh index 2f30cff2..a30b59f0 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -68,6 +68,9 @@ case $POWERLEVEL9K_MODE in VCS_BRANCH_ICON $'\uE220' #  VCS_REMOTE_BRANCH_ICON ' '$'\uE804 ' #  VCS_GIT_ICON $'\uE20E ' #  + VCS_GIT_GITHUB_ICON $'\uE20E ' # + VCS_GIT_BITBUCKET_ICON $'\uE20E ' # + VCS_GIT_GITLAB_ICON $'\uE20E ' # VCS_HG_ICON $'\uE1C3 ' #  VCS_SVN_ICON '(svn) ' RUST_ICON '' From e7ab1e9eedfce22364b5aeb3c8c96d1c1c766879 Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:06:32 +0100 Subject: [PATCH 05/59] Add service icon definition on fa-regular Add configuration for icons on section 'awesome-fontconfig'. --- functions/icons.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index a30b59f0..b6d277fc 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -124,7 +124,10 @@ case $POWERLEVEL9K_MODE in VCS_COMMIT_ICON $'\uF221 ' #  VCS_BRANCH_ICON $'\uF126' #  VCS_REMOTE_BRANCH_ICON ' '$'\uF204 ' #  - VCS_GIT_ICON $'\uF113 ' #  + VCS_GIT_ICON $'\uF1D3 ' #  + VCS_GIT_GITHUB_ICON $'\uF113 ' #  + VCS_GIT_BITBUCKET_ICON $'\uF171 ' #  + VCS_GIT_GITLAB_ICON $'\uF296 ' #  VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON '(svn) ' RUST_ICON $'\uE6A8' #  From 528e648c048bff1c021e144894b050b0ce2fe7bf Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:07:15 +0100 Subject: [PATCH 06/59] Add service icon definition on Powerline-Patched Fonts Add configuration for service icons in section "Powerline-Patched Font". --- functions/icons.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index b6d277fc..7ae3e5a4 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -182,9 +182,12 @@ case $POWERLEVEL9K_MODE in VCS_BRANCH_ICON $'\uE0A0 ' #  VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON '' + VCS_GIT_GITHUB_ICON '' + VCS_GIT_BITBUCKET_ICON '' + VCS_GIT_GITLAB_ICON '' VCS_HG_ICON '' VCS_SVN_ICON '' - RUST_ICON '' + RUST_ICON '' PYTHON_ICON '' ) ;; From f2cac2273a662127cf9dc25471047cdd0c116701 Mon Sep 17 00:00:00 2001 From: David Paz Date: Thu, 15 Dec 2016 13:08:21 +0100 Subject: [PATCH 07/59] Assign git service icon depending on repo origin Check git origin url to search for well know services. Return proper icon if service found, if not return "git" icon from font-awesome icon set --- functions/vcs.zsh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/functions/vcs.zsh b/functions/vcs.zsh index a0aa2b6c..2a461659 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -110,7 +110,18 @@ function +vi-hg-bookmarks() { function +vi-vcs-detect-changes() { if [[ "${hook_com[vcs]}" == "git" ]]; then - vcs_visual_identifier='VCS_GIT_ICON' + + local remote=`git ls-remote --get-url` + if [[ "$remote" =~ "github" ]] then + vcs_visual_identifier='VCS_GIT_GITHUB_ICON' + elif [[ "$remote" =~ "bitbucket" ]] then + vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' + elif [[ "$remote" =~ "gitlab" ]] then + vcs_visual_identifier='VCS_GIT_GITLAB_ICON' + else + vcs_visual_identifier='VCS_GIT_ICON' + fi + elif [[ "${hook_com[vcs]}" == "hg" ]]; then vcs_visual_identifier='VCS_HG_ICON' elif [[ "${hook_com[vcs]}" == "svn" ]]; then From 881ce33263c596d8cbe4d9099345d48de997c408 Mon Sep 17 00:00:00 2001 From: Christian Rebischke Date: Sun, 11 Dec 2016 05:16:02 +0100 Subject: [PATCH 08/59] added virtualization detection with systemd --- README.md | 1 + powerlevel9k.zsh-theme | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 2d031706..f72589cb 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ The segments that are currently available are: * [`custom_command`](#custom_command) - Create a custom segment to display the output of an arbitrary command. * [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file. +* `detect-virt` - Virtualization detection with systemd --------------------------------------------------------------------------------- diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c06d1286..49e066a5 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -538,6 +538,26 @@ prompt_history() { "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" '%h' } +# Detection for virtualization (systemd based systems only) +prompt_detect_virt() { + if ! command -v systemd-detect-virt;then + return + fi + local virt=$(systemd-detect-virt) + local color="yellow" + if [[ "$virt" == "none" ]]; then + if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then + virt="chroot" + "$1_prompt_segment" "$0" "$2" "$color" "$virt" "" + else + ; + fi + else + "$1_prompt_segment" "$0" "$2" "$color" "$virt" "" + fi +} + + prompt_icons_test() { for key in ${(@k)icons}; do # The lower color spectrum in ZSH makes big steps. Choosing From 16283fc8ee5c2f249723ed185abe70a111e479ca Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 19 Dec 2016 15:34:04 -0700 Subject: [PATCH 09/59] migrated battery segment to use pmset on OSX over ioreg --- powerlevel9k.zsh-theme | 48 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index d574e3b5..13e308bc 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -350,43 +350,35 @@ prompt_battery() { # Set default values if the user did not configure them set_default POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 - if [[ $OS =~ OSX && -f /usr/sbin/ioreg && -x /usr/sbin/ioreg ]]; then - # Pre-Grep as much information as possible to save some memory and - # avoid pollution of the xtrace output. - local raw_data="$(ioreg -n AppleSmartBattery | grep -E "MaxCapacity|TimeRemaining|CurrentCapacity|ExternalConnected|IsCharging")" + if [[ $OS =~ OSX && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then + # obtain battery information from system + local raw_data="$(pmset -g batt)" # return if there is no battery on system - [[ -z $(echo $raw_data | grep MaxCapacity) ]] && return + [[ -z $(echo $raw_data | grep "InternalBattery") ]] && return - # Convert time remaining from minutes to hours:minutes date string - local time_remaining=$(echo $raw_data | grep TimeRemaining | awk '{ print $5 }') - if [[ -n $time_remaining ]]; then - # this value is set to a very high number when the system is calculating - [[ $time_remaining -gt 10000 ]] && local tstring="..." || local tstring=${(f)$(/bin/date -u -r $(($time_remaining * 60)) +%k:%M)} - fi + # Time remaining on battery operation (charging/discharging) + local tstring=$(echo $raw_data | awk 'FNR==2{print $5}') + [[ $tstring =~ '\(no' ]] && tstring="..." - # Get charge values - local max_capacity=$(echo $raw_data | grep MaxCapacity | awk '{ print $5 }') - local current_capacity=$(echo $raw_data | grep CurrentCapacity | awk '{ print $5 }') - - if [[ -n "$max_capacity" && -n "$current_capacity" ]]; then - typeset -i 10 bat_percent - bat_percent=$(( (current_capacity * 100) / max_capacity )) - fi + # percent of battery charged + typeset -i 10 bat_percent + bat_percent=$(echo $raw_data | grep -o '[0-9]*%' | sed 's/%//') local remain="" # Logic for string output - if [[ $(echo $raw_data | grep ExternalConnected | awk '{ print $5 }') =~ "Yes" ]]; then - # Battery is charging - if [[ $(echo $raw_data | grep IsCharging | awk '{ print $5 }') =~ "Yes" ]]; then + case $(echo $raw_data | awk 'FNR==2{print $4}') in + 'charging;|finishing charge;') current_state="charging" remain=" ($tstring)" - else + ;; + 'discharging;') + [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" + remain=" ($tstring)" + ;; + *) current_state="charged" - fi - else - [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" - remain=" ($tstring)" - fi + ;; + esac fi if [[ $OS =~ Linux ]]; then From 4568c3490d1c54264c916e9af1e910c766a37b20 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 19 Dec 2016 16:34:08 -0700 Subject: [PATCH 10/59] added a comment --- powerlevel9k.zsh-theme | 1 + 1 file changed, 1 insertion(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 13e308bc..b440b0a3 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -358,6 +358,7 @@ prompt_battery() { # Time remaining on battery operation (charging/discharging) local tstring=$(echo $raw_data | awk 'FNR==2{print $5}') + # If time has not been calculated by system yet [[ $tstring =~ '\(no' ]] && tstring="..." # percent of battery charged From 29233c1963ce85241972e7962b92c73535e4a1d6 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:04:18 -0700 Subject: [PATCH 11/59] added public IP segment for review/discussion --- functions/icons.zsh | 5 ++++- powerlevel9k.zsh-theme | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 06d6ab20..b13e3463 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -76,6 +76,7 @@ case $POWERLEVEL9K_MODE in RUST_ICON '' PYTHON_ICON $'\U1F40D' # 🐍 SWIFT_ICON '' + PUBLIC_IP_ICON '' ) ;; 'awesome-fontconfig') @@ -131,9 +132,10 @@ 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 $'\U1F40D' # 🐍 SWIFT_ICON '' + PUBLIC_IP_ICON '' ) ;; *) @@ -192,6 +194,7 @@ case $POWERLEVEL9K_MODE in RUST_ICON '' PYTHON_ICON '' SWIFT_ICON 'Swift' + PUBLIC_IP_ICON '' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9ea12aa7..34d1f640 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -426,6 +426,51 @@ prompt_battery() { fi } +prompt_public_ip() { + # set default values for segment + set_default POWERLEVEL9K_PUBLIC_IP_TIMOUT "300" + set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" + set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" + + # Do we need a fresh IP? + local refresh_ip=FALSE + if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + typeset -i timediff + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + [[ $timediff -gt '500' ]] && refresh_ip=TRUE + # this will run the IP refresh with each new prompt while disconnected + # but will get a new IP immediately once reconnected rather than waiting + # for the timeout, not sure if this is ideal behavior or not + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=TRUE + else + touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=TRUE + fi + + # grab a fresh IP if needed + if [[ $refresh_ip =~ 'TRUE' && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + if type -p dig >/dev/null; then + fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" + [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip + fi + + if [[ -z "$fresh_ip" ]] && type -p curl >/dev/null; then + fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + + if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then + fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE + fi + + # write IP to tmp file + local public_ip=$(cat $POWERLEVEL9K_PUBLIC_IP_FILE) + + if [[ -n $public_ip ]]; then + $1_prompt_segment "$0" "$2" "black" "249" "${public_ip}" 'PUBLIC_IP_ICON' + fi +} + # Context: user@hostname (who am I and where am I) # Note that if $DEFAULT_USER is not set, this prompt segment will always print prompt_context() { From 2ddf2a2f2039e6f800be620e5d82b94c68019364 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:09:43 -0700 Subject: [PATCH 12/59] fixed colors to defaults --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 34d1f640..65d3b11d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -467,7 +467,7 @@ prompt_public_ip() { local public_ip=$(cat $POWERLEVEL9K_PUBLIC_IP_FILE) if [[ -n $public_ip ]]; then - $1_prompt_segment "$0" "$2" "black" "249" "${public_ip}" 'PUBLIC_IP_ICON' + $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" 'PUBLIC_IP_ICON' fi } From fa21bfff4595eb9451917ed219d29b83ea74c2e4 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:10:43 -0700 Subject: [PATCH 13/59] reverted trailing space edit --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index b13e3463..77015f0b 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -132,7 +132,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 $'\U1F40D' # 🐍 SWIFT_ICON '' PUBLIC_IP_ICON '' From 80ee16c16dbd745717e478e8bccc0454fcdf010f Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 20:07:26 -0700 Subject: [PATCH 14/59] added custom host depth to context segment --- powerlevel9k.zsh-theme | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9ea12aa7..9e89f68d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -429,12 +429,13 @@ prompt_battery() { # Context: user@hostname (who am I and where am I) # Note that if $DEFAULT_USER is not set, this prompt segment will always print prompt_context() { + set_default POWERLEVEL9K_CONTEXT_HOST_DEPTH "%m" if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then if [[ $(print -P "%#") == '#' ]]; then # Shell runs as root - "$1_prompt_segment" "$0_ROOT" "$2" "$DEFAULT_COLOR" "yellow" "$USER@%m" + "$1_prompt_segment" "$0_ROOT" "$2" "$DEFAULT_COLOR" "yellow" "$USER@$POWERLEVEL9K_CONTEXT_HOST_DEPTH" else - "$1_prompt_segment" "$0_DEFAULT" "$2" "$DEFAULT_COLOR" "011" "$USER@%m" + "$1_prompt_segment" "$0_DEFAULT" "$2" "$DEFAULT_COLOR" "011" "$USER@$POWERLEVEL9K_CONTEXT_HOST_DEPTH" fi fi } From 37145ef14d854bfb7ca65145e9bd86cefcfba060 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 20:13:55 -0700 Subject: [PATCH 15/59] added documentation for custom host depth to README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index ef3207ac..54b5c519 100644 --- a/README.md +++ b/README.md @@ -240,9 +240,17 @@ it, but only display it if you are not your normal user or on a remote host 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`: +You can set the `POWERLEVEL9K_CONTEXT_HOST_DEPTH` variable to change how the +hostname is displayed. See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information] +for details. Default is set to %m which will show the hostname up to the first ‘.’ +You can set it to %{N}m where N is an integer to show that many segments of system +hostname. Setting N to a negative integer will show that many segments from the +end of the hostname. + | Variable | Default Value | Description | |----------|---------------|-------------| |`DEFAULT_USER`|None|Username to consider a "default context" (you can also use `$USER`)| +|`POWERLEVEL9K_CONTEXT_HOST_DEPTH`|%m|Customizable host depth on prompt| ##### dir From cf88f861fa29d0d78ca08c7f831717945abb94eb Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Sun, 1 Jan 2017 23:47:01 -0700 Subject: [PATCH 16/59] fixed boolean values --- powerlevel9k.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 65d3b11d..437a1fb1 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -433,21 +433,21 @@ prompt_public_ip() { set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" # Do we need a fresh IP? - local refresh_ip=FALSE + local refresh_ip=false if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then typeset -i timediff timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) - [[ $timediff -gt '500' ]] && refresh_ip=TRUE + [[ $timediff -gt '500' ]] && refresh_ip=true # this will run the IP refresh with each new prompt while disconnected # but will get a new IP immediately once reconnected rather than waiting # for the timeout, not sure if this is ideal behavior or not - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=TRUE + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true else - touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=TRUE + touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true fi # grab a fresh IP if needed - if [[ $refresh_ip =~ 'TRUE' && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then if type -p dig >/dev/null; then fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip From 5fdfd63e467853a0b69267d8426fa99005b59b17 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:04:18 -0700 Subject: [PATCH 17/59] added public IP segment for review/discussion --- functions/icons.zsh | 5 ++++- powerlevel9k.zsh-theme | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 06d6ab20..b13e3463 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -76,6 +76,7 @@ case $POWERLEVEL9K_MODE in RUST_ICON '' PYTHON_ICON $'\U1F40D' # 🐍 SWIFT_ICON '' + PUBLIC_IP_ICON '' ) ;; 'awesome-fontconfig') @@ -131,9 +132,10 @@ 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 $'\U1F40D' # 🐍 SWIFT_ICON '' + PUBLIC_IP_ICON '' ) ;; *) @@ -192,6 +194,7 @@ case $POWERLEVEL9K_MODE in RUST_ICON '' PYTHON_ICON '' SWIFT_ICON 'Swift' + PUBLIC_IP_ICON '' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9e89f68d..dd0ad0ec 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -426,6 +426,51 @@ prompt_battery() { fi } +prompt_public_ip() { + # set default values for segment + set_default POWERLEVEL9K_PUBLIC_IP_TIMOUT "300" + set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" + set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" + + # Do we need a fresh IP? + local refresh_ip=FALSE + if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + typeset -i timediff + timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) + [[ $timediff -gt '500' ]] && refresh_ip=TRUE + # this will run the IP refresh with each new prompt while disconnected + # but will get a new IP immediately once reconnected rather than waiting + # for the timeout, not sure if this is ideal behavior or not + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=TRUE + else + touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=TRUE + fi + + # grab a fresh IP if needed + if [[ $refresh_ip =~ 'TRUE' && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + if type -p dig >/dev/null; then + fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" + [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip + fi + + if [[ -z "$fresh_ip" ]] && type -p curl >/dev/null; then + fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + + if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then + fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE + fi + + # write IP to tmp file + local public_ip=$(cat $POWERLEVEL9K_PUBLIC_IP_FILE) + + if [[ -n $public_ip ]]; then + $1_prompt_segment "$0" "$2" "black" "249" "${public_ip}" 'PUBLIC_IP_ICON' + fi +} + # Context: user@hostname (who am I and where am I) # Note that if $DEFAULT_USER is not set, this prompt segment will always print prompt_context() { From a6c8c5c2dd62474095d9213f34193bb0a3d5b9dd Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:09:43 -0700 Subject: [PATCH 18/59] fixed colors to defaults --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dd0ad0ec..dfc37d2c 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -467,7 +467,7 @@ prompt_public_ip() { local public_ip=$(cat $POWERLEVEL9K_PUBLIC_IP_FILE) if [[ -n $public_ip ]]; then - $1_prompt_segment "$0" "$2" "black" "249" "${public_ip}" 'PUBLIC_IP_ICON' + $1_prompt_segment "$0" "$2" "$DEFAULT_COLOR" "$DEFAULT_COLOR_INVERTED" "${public_ip}" 'PUBLIC_IP_ICON' fi } From 0682105ae8baafd695b58094f8e44a589cc9d236 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Fri, 30 Dec 2016 14:10:43 -0700 Subject: [PATCH 19/59] reverted trailing space edit --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index b13e3463..77015f0b 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -132,7 +132,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 $'\U1F40D' # 🐍 SWIFT_ICON '' PUBLIC_IP_ICON '' From 5cf78c5a1314967b86e37dc330f889e3c5cba805 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Sun, 1 Jan 2017 23:47:01 -0700 Subject: [PATCH 20/59] fixed boolean values --- powerlevel9k.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dfc37d2c..f5c810bc 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -433,21 +433,21 @@ prompt_public_ip() { set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" # Do we need a fresh IP? - local refresh_ip=FALSE + local refresh_ip=false if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then typeset -i timediff timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) - [[ $timediff -gt '500' ]] && refresh_ip=TRUE + [[ $timediff -gt '500' ]] && refresh_ip=true # this will run the IP refresh with each new prompt while disconnected # but will get a new IP immediately once reconnected rather than waiting # for the timeout, not sure if this is ideal behavior or not - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=TRUE + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true else - touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=TRUE + touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true fi # grab a fresh IP if needed - if [[ $refresh_ip =~ 'TRUE' && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then + if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then if type -p dig >/dev/null; then fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip From fa51798ce76fd5e50ac7be2fee333e090697ef17 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Tue, 3 Jan 2017 16:05:15 -0700 Subject: [PATCH 21/59] fixed some comments and handled an edge case --- powerlevel9k.zsh-theme | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f5c810bc..dd57ac05 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -460,10 +460,11 @@ prompt_public_ip() { if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" fi - [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE + # write IP to tmp file or touch tmp file if an IP was not retrieved + [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE || touch $POWERLEVEL9K_PUBLIC_IP_FILE fi - # write IP to tmp file + # read public IP saved to tmp file local public_ip=$(cat $POWERLEVEL9K_PUBLIC_IP_FILE) if [[ -n $public_ip ]]; then From 6c46410a2f300a015254b3662b06ab572815c9f3 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Tue, 3 Jan 2017 16:55:33 -0700 Subject: [PATCH 22/59] updated some comments changed some offline behavior --- powerlevel9k.zsh-theme | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 3693f02d..22e61d62 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -436,11 +436,10 @@ prompt_public_ip() { local refresh_ip=false if [[ -f $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then typeset -i timediff + # if saved IP is more than timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) - [[ $timediff -gt '500' ]] && refresh_ip=true - # this will run the IP refresh with each new prompt while disconnected - # but will get a new IP immediately once reconnected rather than waiting - # for the timeout, not sure if this is ideal behavior or not + [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMOUT ]] && refresh_ip=true + # If tmp file is empty get a fresh IP [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true else touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true @@ -461,8 +460,8 @@ prompt_public_ip() { fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" fi - # write IP to tmp file or touch tmp file if an IP was not retrieved - [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE || touch $POWERLEVEL9K_PUBLIC_IP_FILE + # write IP to tmp file or clear tmp file if an IP was not retrieved + [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE || echo "" > $POWERLEVEL9K_PUBLIC_IP_FILE fi # read public IP saved to tmp file From 1b838241fb5fe6628a00acae7d154c51615b6458 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Tue, 3 Jan 2017 17:07:52 -0700 Subject: [PATCH 23/59] added configurable string when there is no IP --- powerlevel9k.zsh-theme | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 22e61d62..193a1a85 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -429,6 +429,7 @@ prompt_battery() { prompt_public_ip() { # set default values for segment set_default POWERLEVEL9K_PUBLIC_IP_TIMOUT "300" + set_default POWERLEVEL9K_PUBLIC_IP_NONE "" set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" @@ -440,7 +441,7 @@ prompt_public_ip() { timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMOUT ]] && refresh_ip=true # If tmp file is empty get a fresh IP - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) || $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ $POWERLEVEL9K_PUBLIC_IP_NONE ]] && refresh_ip=true else touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true fi @@ -461,7 +462,7 @@ prompt_public_ip() { fi # write IP to tmp file or clear tmp file if an IP was not retrieved - [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE || echo "" > $POWERLEVEL9K_PUBLIC_IP_FILE + [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE || echo $POWERLEVEL9K_PUBLIC_IP_NONE > $POWERLEVEL9K_PUBLIC_IP_FILE fi # read public IP saved to tmp file From c1cd7a2b088272cc13938f207525aef03e79bb44 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 8 Jan 2017 22:16:01 +0100 Subject: [PATCH 24/59] Add Changelog for v0.5.0 --- CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a3f7444..34ae0c77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## v0.5.0 + +### `load` and `ram` changes + +These two segments now support BSD. + +### `vcs` changes + +- We implemented a huge speed improvement for this segment. +- Now this segment supports Subversion repositories. +- Add ability to hide tags by setting `POWERLEVEL9K_VCS_HIDE_TAGS` to true. + +## `anaconda` changes + +Speed improvements for `anaconda` segment. + ## v0.4.0 ### Development changes @@ -77,6 +93,11 @@ Added new `docker_machine` segment that will show your Docker machine. A new segment `anaconda` was added that shows the current used anaconda environment. +## New segment `pyenv` added + +This segment shows your active python version as reported by `pyenv`. + + ## v0.3.2 ### `vcs` changes From 20a5556642c4cca23d4b65e05fa64999c492a13d Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 14:41:46 -0700 Subject: [PATCH 25/59] added the ability to specify and only attempt a particular method --- powerlevel9k.zsh-theme | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 437a1fb1..ef945613 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -448,17 +448,42 @@ prompt_public_ip() { # grab a fresh IP if needed if [[ $refresh_ip =~ true && -w $POWERLEVEL9K_PUBLIC_IP_FILE ]]; then - if type -p dig >/dev/null; then - fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" - [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip + # if method specified, don't use fallback methods + if [[ -n $POWERLEVEL9K_PUBLIC_IP_METHOD ]] && [[ $POWERLEVEL9K_PUBLIC_IP_METHOD =~ 'wget|curl|dig' ]]; then + local method=$POWERLEVEL9K_PUBLIC_IP_METHOD fi + if [[ -n $method ]]; then + case $method in + 'dig') + if type -p dig >/dev/null; then + fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" + [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip + fi + ;; + 'curl') + if [[ -z "$fresh_ip" ]] && type -p curl >/dev/null; then + fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + ;; + 'wget') + if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then + fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi + ;; + esac + else + if type -p dig >/dev/null; then + fresh_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2> /dev/null)" + [[ "$fresh_ip" =~ ^\; ]] && unset fresh_ip + fi - if [[ -z "$fresh_ip" ]] && type -p curl >/dev/null; then - fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" - fi + if [[ -z "$fresh_ip" ]] && type -p curl >/dev/null; then + fresh_ip="$(curl --max-time 10 -w '\n' "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi - if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then - fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + if [[ -z "$fresh_ip" ]] && type -p wget >/dev/null; then + fresh_ip="$(wget -T 10 -qO- "$POWERLEVEL9K_PUBLIC_IP_HOST" 2> /dev/null)" + fi fi [[ -n $fresh_ip ]] && echo $fresh_ip > $POWERLEVEL9K_PUBLIC_IP_FILE fi From 6e1e4ac241fcc113170f28656c99ef9b821aba9a Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 14:53:28 -0700 Subject: [PATCH 26/59] added README section for public_ip segment --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 54b5c519..87fd9182 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,29 @@ specify the correct network interface by setting: |----------|---------------|-------------| |`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.| +##### public_ip + +This segment will display your public IP address. There are several methods of obtaining this +information and by default it will try all of them starting with the most efficient. You can +also specify which method you would like it to use. The methods available are dig using opendns, +curl, or wget. The host used for wget and curl is http://ident.me by default but can be set to +another host if you prefer. + +The public_ip segment will attempt to update your public IP address every 5 minutes by default(also +configurable by the user). If you lose connection your cached IP address will be displayed until +your timeout expires at which point every time your prompt is generated a new attempt will be made. +Until an IP is successfully pulled the value of $POWERLEVEL9K_PUBLIC_IP_NONE will be displayed for +this segment. If this value is empty(the default)and $POWERLEVEL9K_PUBLIC_IP_FILE is empty the +segment will not be displayed. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| +|`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| +|`POWERLEVEL9K_PUBLIC_IP_TIMOUT`|300|The amount of time in seconds between refreshing your cached IP.| +|`POWERLEVEL9K_PUBLIC_IP_METHOD`|None|You can set this to any of 'dig', 'curl', or 'wget' to only use that method to refresh your IP.| +|`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| + ##### rbenv This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack. From f33f843e92c565453b253531d9d7be06faaf42fc Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 14:56:22 -0700 Subject: [PATCH 27/59] fixed issue with POWERLEVEL9K_PUBLIC_IP_NONE being empty --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 10d1564e..368254ee 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -441,7 +441,7 @@ prompt_public_ip() { timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMOUT ]] && refresh_ip=true # If tmp file is empty get a fresh IP - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) || $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ $POWERLEVEL9K_PUBLIC_IP_NONE ]] && refresh_ip=true + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) || $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ '$POWERLEVEL9K_PUBLIC_IP_NONE' ]] && refresh_ip=true else touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true fi From f11ca0664c9d9aba9d456b70058ba64909e1e098 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 15:00:20 -0700 Subject: [PATCH 28/59] fixed issue with POWERLEVEL9K_PUBLIC_IP_NONE being empty for real --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 368254ee..78b014e5 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -429,7 +429,7 @@ prompt_battery() { prompt_public_ip() { # set default values for segment set_default POWERLEVEL9K_PUBLIC_IP_TIMOUT "300" - set_default POWERLEVEL9K_PUBLIC_IP_NONE "" + set_default POWERLEVEL9K_PUBLIC_IP_NONE "none" set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" @@ -441,7 +441,7 @@ prompt_public_ip() { timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMOUT ]] && refresh_ip=true # If tmp file is empty get a fresh IP - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) || $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ '$POWERLEVEL9K_PUBLIC_IP_NONE' ]] && refresh_ip=true + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) || $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ "$POWERLEVEL9K_PUBLIC_IP_NONE" ]] && refresh_ip=true else touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true fi From f5b544f4c8229291c83d7c9feef4546544ae5372 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 15:06:14 -0700 Subject: [PATCH 29/59] added link to segemnt documenation in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 87fd9182..ee1648f8 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ The segments that are currently available are: * [`dir`](#dir) - Your current working directory. * `history` - The command number for the current line. * [`ip`](#ip) - Shows the current IP address. +* [`public_ip`](#public_ip) - Shows your public IP address. * `load` - Your machine's load averages. * `os_icon` - Display a nice little icon, depending on your operating system. * `ram` - Show free RAM. From 2cc6e661b473339e8f39489f879b2f19a2ebf856 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 15:14:05 -0700 Subject: [PATCH 30/59] reverted testing value to default value --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 78b014e5..05bf3d14 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -429,7 +429,7 @@ prompt_battery() { prompt_public_ip() { # set default values for segment set_default POWERLEVEL9K_PUBLIC_IP_TIMOUT "300" - set_default POWERLEVEL9K_PUBLIC_IP_NONE "none" + set_default POWERLEVEL9K_PUBLIC_IP_NONE "" set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" From 2cb1f84ce7fa135c480712e684d67c03299a3615 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 15:24:50 -0700 Subject: [PATCH 31/59] fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ee1648f8..2ad799c4 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,7 @@ segment will not be displayed. |----------|---------------|-------------| |`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| |`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| -|`POWERLEVEL9K_PUBLIC_IP_TIMOUT`|300|The amount of time in seconds between refreshing your cached IP.| +|`POWERLEVEL9K_PUBLIC_IP_TIEMOUT`|300|The amount of time in seconds between refreshing your cached IP.| |`POWERLEVEL9K_PUBLIC_IP_METHOD`|None|You can set this to any of 'dig', 'curl', or 'wget' to only use that method to refresh your IP.| |`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| From 108335f18f95fd9cbd63157699925202b4df72d9 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 15:25:02 -0700 Subject: [PATCH 32/59] fixed typo fixed issue with POWERLEVEL9K_PUBLIC_IP_NONE being empty .. i hope --- powerlevel9k.zsh-theme | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 05bf3d14..95a2a5ea 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -428,7 +428,7 @@ prompt_battery() { prompt_public_ip() { # set default values for segment - set_default POWERLEVEL9K_PUBLIC_IP_TIMOUT "300" + set_default POWERLEVEL9K_PUBLIC_IP_TIMEOUT "300" set_default POWERLEVEL9K_PUBLIC_IP_NONE "" set_default POWERLEVEL9K_PUBLIC_IP_FILE "/tmp/p9k_public_ip" set_default POWERLEVEL9K_PUBLIC_IP_HOST "http://ident.me" @@ -439,9 +439,10 @@ prompt_public_ip() { typeset -i timediff # if saved IP is more than timediff=$(($(date +%s) - $(date -r $POWERLEVEL9K_PUBLIC_IP_FILE +%s))) - [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMOUT ]] && refresh_ip=true + [[ $timediff -gt $POWERLEVEL9K_PUBLIC_IP_TIMEOUT ]] && refresh_ip=true # If tmp file is empty get a fresh IP - [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) || $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ "$POWERLEVEL9K_PUBLIC_IP_NONE" ]] && refresh_ip=true + [[ -z $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) ]] && refresh_ip=true + [[ -n $POWERLEVEL9K_PUBLIC_IP_NONE ]] && [[ $(cat $POWERLEVEL9K_PUBLIC_IP_FILE) =~ "$POWERLEVEL9K_PUBLIC_IP_NONE" ]] && refresh_ip=true else touch $POWERLEVEL9K_PUBLIC_IP_FILE && refresh_ip=true fi From 57be8cb18a1ee6423b143f3be41fa2bd089552ba Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 9 Jan 2017 17:26:43 -0500 Subject: [PATCH 33/59] Adding the new logo to the README! --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d031706..ede3f835 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -## powerlevel9k Theme for ZSH - +![](https://raw.githubusercontent.com/bhilburn/powerlevel9k-logo/master/logo-banner.png) +--- [![Build Status](https://travis-ci.org/bhilburn/powerlevel9k.svg?branch=next)](https://travis-ci.org/bhilburn/powerlevel9k) [![Join the chat at https://gitter.im/bhilburn/powerlevel9k](https://badges.gitter.im/bhilburn/powerlevel9k.svg)](https://gitter.im/bhilburn/powerlevel9k?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From 6321dd99c5e6050b24598cca8b37d54f520a6ffd Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Mon, 9 Jan 2017 15:30:15 -0700 Subject: [PATCH 34/59] more typos --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ad799c4..ac0f86f4 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,7 @@ segment will not be displayed. |----------|---------------|-------------| |`POWERLEVEL9K_PUBLIC_IP_FILE`|'/tmp/p8k_public_ip'|This is the file your public IP is cached in.| |`POWERLEVEL9K_PUBLIC_IP_HOST`|'http://ident.me'|This is the default host to get your public IP.| -|`POWERLEVEL9K_PUBLIC_IP_TIEMOUT`|300|The amount of time in seconds between refreshing your cached IP.| +|`POWERLEVEL9K_PUBLIC_IP_TIMEOUT`|300|The amount of time in seconds between refreshing your cached IP.| |`POWERLEVEL9K_PUBLIC_IP_METHOD`|None|You can set this to any of 'dig', 'curl', or 'wget' to only use that method to refresh your IP.| |`POWERLEVEL9K_PUBLIC_IP_NONE`|None|The string displayed when an IP was not obtained| From 2891a2f3405a1af0770aee7a13a10eb0abee820b Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 9 Jan 2017 17:39:26 -0500 Subject: [PATCH 35/59] Adding license note about the new logo. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ede3f835..2b85e7fb 100644 --- a/README.md +++ b/README.md @@ -412,4 +412,5 @@ portion of the wiki to get going. information!](https://github.com/bhilburn/powerlevel9k/wiki) ### License -MIT +Project: MIT +Logo: CC-BY-SA. Source repository: https://github.com/bhilburn/powerlevel9k-logo From 5f41b5e17e52a7eb34216173b4bc7dd82361cd76 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 9 Jan 2017 17:40:29 -0500 Subject: [PATCH 36/59] Minor fix-up to the README. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2b85e7fb..82650131 100644 --- a/README.md +++ b/README.md @@ -412,5 +412,7 @@ portion of the wiki to get going. information!](https://github.com/bhilburn/powerlevel9k/wiki) ### License + Project: MIT + Logo: CC-BY-SA. Source repository: https://github.com/bhilburn/powerlevel9k-logo From 22540e04b83570ac77d903e918b14b17b42f38e0 Mon Sep 17 00:00:00 2001 From: James Short Date: Wed, 18 Jan 2017 14:50:00 -0800 Subject: [PATCH 37/59] Fix MacOS specific battery segment logic. The case statement was causing it to never display that it was charging and some of the awk statements had an off-by-one bug to grab the correct values. --- powerlevel9k.zsh-theme | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9e89f68d..8a6fe1c9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -339,7 +339,7 @@ prompt_background_jobs() { prompt_battery() { # The battery can have four different states - default to 'unknown'. - local current_state="unknown" + local current_state='unknown' typeset -AH battery_states battery_states=( 'low' 'red' @@ -352,14 +352,14 @@ prompt_battery() { if [[ $OS =~ OSX && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then # obtain battery information from system - local raw_data="$(pmset -g batt)" + local raw_data="$(pmset -g batt | awk 'FNR==2{print}')" # return if there is no battery on system [[ -z $(echo $raw_data | grep "InternalBattery") ]] && return # Time remaining on battery operation (charging/discharging) - local tstring=$(echo $raw_data | awk 'FNR==2{print $5}') + local tstring=$(echo $raw_data | awk -F ';' '{print $3}' | awk '{print $1}') # If time has not been calculated by system yet - [[ $tstring =~ '\(no' ]] && tstring="..." + [[ $tstring =~ '(\(no|not)' ]] && tstring="..." # percent of battery charged typeset -i 10 bat_percent @@ -367,12 +367,13 @@ prompt_battery() { local remain="" # Logic for string output - case $(echo $raw_data | awk 'FNR==2{print $4}') in - 'charging;|finishing charge;') + case $(echo $raw_data | awk -F ';' '{print $2}' | awk '{$1=$1};1') in + # for a short time after attaching power, status will be 'AC attached;' + 'charging'|'finishing charge'|'AC attached') current_state="charging" remain=" ($tstring)" ;; - 'discharging;') + 'discharging') [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && current_state="low" || current_state="disconnected" remain=" ($tstring)" ;; From e2b2e8e173af682c2a326f15f885ede68151b896 Mon Sep 17 00:00:00 2001 From: Owen McGill Date: Thu, 19 Jan 2017 14:48:57 -0700 Subject: [PATCH 38/59] Change powerlevel9k_init to prompt_powerlevel_setup Changed init/setup function name to be compatible with zsh promptinit, zsh prompt function only lists themes with prompt_*_setup init/setup functions --- powerlevel9k.zsh-theme | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 4c9c75c7..c3f2be74 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1147,7 +1147,7 @@ $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" fi } -powerlevel9k_init() { +prompt_powerlevel9k_setup() { # Display a warning if the terminal does not support 256 colors local term_colors term_colors=$(echotc Co) @@ -1199,4 +1199,5 @@ powerlevel9k_init() { add-zsh-hook precmd powerlevel9k_prepare_prompts } -powerlevel9k_init "$@" +prompt_powerlevel9k_setup "$@" + From 95f0c3c6ecd2fc1edfd1b768150237d682426890 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 21:59:59 -0500 Subject: [PATCH 39/59] fixing the "OK_ICON" in 'awesome-fontconfig' which somehow got broken --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 2f30cff2..2920cfd5 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -92,7 +92,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uF291' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 - OK_ICON $'\uF23A' #  + OK_ICON $'\u2713' # ✓ FAIL_ICON $'\uF281' #  SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ From c8cc891045b6e49ff5c8c10a735af94f689dbf7f Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 22:04:16 -0500 Subject: [PATCH 40/59] same deal for the "FAIL_ICON"! --- functions/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 2920cfd5..5e1fcd3d 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -93,7 +93,7 @@ case $POWERLEVEL9K_MODE in TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 OK_ICON $'\u2713' # ✓ - FAIL_ICON $'\uF281' #  + FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' NODE_ICON $'\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─ From 46ef589b63d62c30d52f7cfa06520989eb3ac7da Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:15:24 +0500 Subject: [PATCH 41/59] Add anion155's HDD segment --- functions/icons.zsh | 2 ++ powerlevel9k.zsh-theme | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/functions/icons.zsh b/functions/icons.zsh index eb526f0b..e5cfe6f2 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -34,6 +34,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uE891' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\uE894' #  + HDD_ICON $'\uD83D\uDDB4' # 🖴 OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -97,6 +98,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uF291' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 + HDD_ICON $'\uF0A0 ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c3f2be74..7d948800 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -337,6 +337,50 @@ prompt_background_jobs() { fi } +# Segment to indicate hdd available level. +prompt_hdd_usage() { + local current_state="unknown" + typeset -AH hdd_usage_states + hdd_usage_states=( + 'normal' 'green' + 'warning' 'yellow' + 'critical' 'red' + ) + + # local df="$(df -k . | sed -n '2p')" + # local size="$(echo $df | awk '{ print $2 }')" + # local avail="$(echo $df | awk '{ print $4 }')" + # local level="$(printf %.0f $(( avail * 100.0 / size )))" + local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + level="$(( 100 - level ))" + + set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 + set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 + + if [ $level -gt $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then + # Default behavior: Show message always + set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false + if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then + return + fi + fi + + current_state='normal' + if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then + current_state='warning' + fi + if [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then + current_state='critical' + fi + + local message="$level" + + # Draw the prompt_segment + if [[ -n $level ]]; then + "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${hdd_usage_states[$current_state]}" "$message" 'HDD_ICON' + fi +} + prompt_battery() { # The battery can have four different states - default to 'unknown'. local current_state='unknown' From 41588e0d249d328ef862b779b1c8ef752a94ca81 Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:24:31 +0500 Subject: [PATCH 42/59] Change colors --- powerlevel9k.zsh-theme | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7d948800..f5208c72 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -340,9 +340,15 @@ prompt_background_jobs() { # Segment to indicate hdd available level. prompt_hdd_usage() { local current_state="unknown" - typeset -AH hdd_usage_states - hdd_usage_states=( - 'normal' 'green' + typeset -AH hdd_usage_forecolors + hdd_usage_forecolors=( + 'normal' 'yellow' + 'warning' "$DEFAULT_COLOR" + 'critical' 'white' + ) + typeset -AH hdd_usage_backcolors + hdd_usage_backcolors=( + 'normal' $DEFAULT_COLOR 'warning' 'yellow' 'critical' 'red' ) @@ -366,18 +372,20 @@ prompt_hdd_usage() { fi current_state='normal' + local message="$level%" + if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' + message="$message left" fi if [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then current_state='critical' + message="$message left" fi - local message="$level" - # Draw the prompt_segment if [[ -n $level ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${hdd_usage_states[$current_state]}" "$message" 'HDD_ICON' + "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'HDD_ICON' fi } From 32708784b25f671db09fd3224b4e2d910a48dbbb Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:25:34 +0500 Subject: [PATCH 43/59] Fix --- powerlevel9k.zsh-theme | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f5208c72..1387ecea 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -377,8 +377,7 @@ prompt_hdd_usage() { if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' message="$message left" - fi - if [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then + elif [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then current_state='critical' message="$message left" fi From cf8a94de0167a743da3f38b1ca6ea44903ef66e9 Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:26:32 +0500 Subject: [PATCH 44/59] Fix --- powerlevel9k.zsh-theme | 2 -- 1 file changed, 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1387ecea..6b5decbf 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -376,10 +376,8 @@ prompt_hdd_usage() { if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' - message="$message left" elif [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then current_state='critical' - message="$message left" fi # Draw the prompt_segment From 934186df6d35762f877bb7943db0534f0e50babc Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:27:33 +0500 Subject: [PATCH 45/59] Fix --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6b5decbf..473e17b0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -372,7 +372,7 @@ prompt_hdd_usage() { fi current_state='normal' - local message="$level%" + local message="$level% " if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' From 92cb8d14d1afe25ee8cd2d634cf4948d56921afb Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:28:24 +0500 Subject: [PATCH 46/59] Fix --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 473e17b0..9a1a9100 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -372,7 +372,7 @@ prompt_hdd_usage() { fi current_state='normal' - local message="$level% " + local message="${level}%" if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then current_state='warning' From ea74c45d4fd1a277cba5b694025bdfa29aa52645 Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:39:40 +0500 Subject: [PATCH 47/59] Fix --- powerlevel9k.zsh-theme | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9a1a9100..53862b8c 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -338,6 +338,9 @@ prompt_background_jobs() { } # Segment to indicate hdd available level. +set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false +set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 +set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 prompt_hdd_usage() { local current_state="unknown" typeset -AH hdd_usage_forecolors @@ -357,28 +360,28 @@ prompt_hdd_usage() { # local size="$(echo $df | awk '{ print $2 }')" # local avail="$(echo $df | awk '{ print $4 }')" # local level="$(printf %.0f $(( avail * 100.0 / size )))" - local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" - level="$(( 100 - level ))" - set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 - set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 + # local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + # level="$(( 100 - level ))" + # level="3" - if [ $level -gt $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then + set_default level 10 + + if [ "$level" -gt "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then # Default behavior: Show message always - set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then return fi fi - current_state='normal' - local message="${level}%" - - if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then - current_state='warning' - elif [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then + if [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then current_state='critical' + elif [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then + current_state='warning' + else + current_state='normal' fi + local message="${level}%%" # Draw the prompt_segment if [[ -n $level ]]; then From 7f3677d22a6d6010013e9f17284b70ac84126f3e Mon Sep 17 00:00:00 2001 From: Mikhaylov Anton Date: Mon, 21 Nov 2016 16:41:54 +0500 Subject: [PATCH 48/59] Fix --- powerlevel9k.zsh-theme | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 53862b8c..bee48295 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -361,11 +361,8 @@ prompt_hdd_usage() { # local avail="$(echo $df | awk '{ print $4 }')" # local level="$(printf %.0f $(( avail * 100.0 / size )))" - # local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" - # level="$(( 100 - level ))" - # level="3" - - set_default level 10 + local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + level="$(( 100 - level ))" if [ "$level" -gt "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then # Default behavior: Show message always From ea648d003ec837d329c3a5d3cc53e43f9935b2a2 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 21:17:41 -0500 Subject: [PATCH 49/59] Moving `HDD_ICON` definition to consistent spot. --- functions/icons.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index e5cfe6f2..d2ca9488 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -34,7 +34,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uE891' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\uE894' #  - HDD_ICON $'\uD83D\uDDB4' # 🖴 + HDD_ICON $'\uF0A0 ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -158,6 +158,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON '' TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 + HDD_ICON $'HDD ' OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' From 59b20b8f2780b8a0a3c812cd292393005a1638cb Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 21:45:11 -0500 Subject: [PATCH 50/59] changing `hdd_usage` to actually show usage --- powerlevel9k.zsh-theme | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index bee48295..ec4c60c3 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -337,10 +337,10 @@ prompt_background_jobs() { fi } -# Segment to indicate hdd available level. +# Segment that indicates usage level of current partition. set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false -set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10 -set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5 +set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 90 +set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 95 prompt_hdd_usage() { local current_state="unknown" typeset -AH hdd_usage_forecolors @@ -356,28 +356,20 @@ prompt_hdd_usage() { 'critical' 'red' ) - # local df="$(df -k . | sed -n '2p')" - # local size="$(echo $df | awk '{ print $2 }')" - # local avail="$(echo $df | awk '{ print $4 }')" - # local level="$(printf %.0f $(( avail * 100.0 / size )))" - local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" - level="$(( 100 - level ))" - if [ "$level" -gt "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then - # Default behavior: Show message always - if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then - return - fi - fi - - if [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then - current_state='critical' - elif [ "$level" -le "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then + if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then current_state='warning' + if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then + current_state='critical' + fi else + if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then + return + fi current_state='normal' fi + local message="${level}%%" # Draw the prompt_segment From 64afe83cbd368d45c0ab23c05636b426230fcb57 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 22:24:03 -0500 Subject: [PATCH 51/59] Updating the readme wih `hdd_usage` details. --- CHANGELOG.md | 4 ++++ README.md | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8060e0fa..d21ecaa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Added an option to configure the path separator. If you want something else than an ordinary slash, you could set `POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. +### New segment 'hdd_usage' added + +This segment will show the usage level of your current partition. + ## v0.5.0 ### `load` and `ram` changes diff --git a/README.md b/README.md index f6b8c54c..b1bdf978 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ The segments that are currently available are: * [`battery`](#battery) - Current battery status. * [`context`](#context) - Your username and host. * [`dir`](#dir) - Your current working directory. +* [`hdd_usage`](#hdd_usage) - Disk usage of your current partition. * `history` - The command number for the current line. * [`ip`](#ip) - Shows the current IP address. * [`public_ip`](#public_ip) - Shows your public IP address. @@ -306,6 +307,16 @@ If you want to customize the directory separator, you could set: POWERLEVEL9K_DIR_PATH_SEPARATOR="%f "$'\uE0B1'" %F" ``` +##### hdd_usage + +The `hdd_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables. + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|POWERLEVEL9K_HDD_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| +|POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| +|POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| + ##### ip This segment tries to examine all currently used network interfaces and prints From d2c0a62445dca19dfc4808d73c70d40f784b3e04 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Fri, 20 Jan 2017 22:45:35 -0500 Subject: [PATCH 52/59] vcs icons: fixing branch spacing and remote icon in fontawesome --- functions/icons.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index 5e1fcd3d..575d1f5f 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -65,8 +65,8 @@ case $POWERLEVEL9K_MODE in VCS_TAG_ICON $'\uE817 ' #  VCS_BOOKMARK_ICON $'\uE87B' #  VCS_COMMIT_ICON $'\uE821 ' #  - VCS_BRANCH_ICON $'\uE220' #  - VCS_REMOTE_BRANCH_ICON ' '$'\uE804 ' #  + VCS_BRANCH_ICON $'\uE220 ' #  + VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON $'\uE20E ' #  VCS_HG_ICON $'\uE1C3 ' #  VCS_SVN_ICON '(svn) ' @@ -119,8 +119,8 @@ case $POWERLEVEL9K_MODE in VCS_TAG_ICON $'\uF217 ' #  VCS_BOOKMARK_ICON $'\uF27B' #  VCS_COMMIT_ICON $'\uF221 ' #  - VCS_BRANCH_ICON $'\uF126' #  - VCS_REMOTE_BRANCH_ICON ' '$'\uF204 ' #  + VCS_BRANCH_ICON $'\uF126 ' #  + VCS_REMOTE_BRANCH_ICON $'\u2192' # → VCS_GIT_ICON $'\uF113 ' #  VCS_HG_ICON $'\uF0C3 ' #  VCS_SVN_ICON '(svn) ' From b8e18d710835ff4a3dbd7b19799b731d5930ccbd Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 22 Jan 2017 01:47:58 +0100 Subject: [PATCH 53/59] Fix swift segment The regex for the swift segment matches too much. Here I simplified it to match the first number as this is probably the "main" version number. --- powerlevel9k.zsh-theme | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c3f2be74..dd904278 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1065,12 +1065,10 @@ prompt_pyenv() { # Swift version prompt_swift_version() { - local swift_version=($(swift --version 2>/dev/null)) + # Get the first number as this is probably the "main" version number.. + local swift_version=$(swift --version 2>/dev/null | grep -o -E "[0-9.]+" | head -n 1) [[ -z "${swift_version}" ]] && return - # Extract semantic version - swift_version=$(echo ${swift_version} | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/') - "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' } From 7bd2585371cc28a460543f8ef37c9f93c0d188df Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 21 Jan 2017 21:34:55 -0500 Subject: [PATCH 54/59] incorportaing feedback from review on `hdd_usage` segment --- README.md | 12 ++++++------ functions/icons.zsh | 6 +++--- powerlevel9k.zsh-theme | 23 ++++++++++++----------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b1bdf978..0d3eb303 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ The segments that are currently available are: * [`battery`](#battery) - Current battery status. * [`context`](#context) - Your username and host. * [`dir`](#dir) - Your current working directory. -* [`hdd_usage`](#hdd_usage) - Disk usage of your current partition. +* [`disk_usage`](#disk_usage) - Disk usage of your current partition. * `history` - The command number for the current line. * [`ip`](#ip) - Shows the current IP address. * [`public_ip`](#public_ip) - Shows your public IP address. @@ -307,15 +307,15 @@ If you want to customize the directory separator, you could set: POWERLEVEL9K_DIR_PATH_SEPARATOR="%f "$'\uE0B1'" %F" ``` -##### hdd_usage +##### disk_usage -The `hdd_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables. +The `disk_usage` segment will show the usage level of the partition that your current working directory resides in. It can be configured with the following variables. | Variable | Default Value | Description | |----------|---------------|-------------| -|POWERLEVEL9K_HDD_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| -|POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| -|POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| +|POWERLEVEL9K_DISK_USAGE_ONLY_WARNING|false|Hide the segment except when usage levels have hit warning or critical levels.| +|POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.| +|POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.| ##### ip diff --git a/functions/icons.zsh b/functions/icons.zsh index d2ca9488..84483b40 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -34,7 +34,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uE891' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\uE894' #  - HDD_ICON $'\uF0A0 ' #  + DISK_ICON $'\uE1AE ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -98,7 +98,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON $'\uF291' #  TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 - HDD_ICON $'\uF0A0 ' #  + DISK_ICON $'\uF0A0 ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -158,7 +158,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON '' TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 - HDD_ICON $'HDD ' + DISK_ICON $'hdd ' OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index ec4c60c3..f2e32582 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -338,10 +338,10 @@ prompt_background_jobs() { } # Segment that indicates usage level of current partition. -set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false -set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 90 -set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 95 -prompt_hdd_usage() { +set_default POWERLEVEL9K_DISK_USAGE_ONLY_WARNING false +set_default POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL 90 +set_default POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL 95 +prompt_disk_usage() { local current_state="unknown" typeset -AH hdd_usage_forecolors hdd_usage_forecolors=( @@ -356,25 +356,26 @@ prompt_hdd_usage() { 'critical' 'red' ) - local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}" + local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}" - if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL" ]; then + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then current_state='warning' - if [ "$level" -ge "$POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL" ]; then + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then current_state='critical' fi else - if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then + if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then + current_state='' return fi current_state='normal' fi - local message="${level}%%" + local message="${disk_usage}%%" # Draw the prompt_segment - if [[ -n $level ]]; then - "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'HDD_ICON' + if [[ -n $disk_usage ]]; then + "$1_prompt_segment" "${0}_${current_state}" "$2" "${hdd_usage_backcolors[$current_state]}" "${hdd_usage_forecolors[$current_state]}" "$message" 'DISK_ICON' fi } From 81e9fef9e9ed95499c572415eaa78b343746068f Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sat, 21 Jan 2017 21:38:45 -0500 Subject: [PATCH 55/59] updating changelog for segment name change `disk_usage` --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d21ecaa5..ff0fd890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Added an option to configure the path separator. If you want something else than an ordinary slash, you could set `POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. -### New segment 'hdd_usage' added +### New segment 'disk_usage' added This segment will show the usage level of your current partition. From 1a2439926fb1df356e9ca0bc5ca937c01c64fcd2 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 22 Jan 2017 13:13:11 -0500 Subject: [PATCH 56/59] README: default segment list was no longer accurate --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0d3eb303..840ee156 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ Here is `powerlevel9k` in action, with [some simple settings](https://github.com Be sure to also [check out the Wiki](https://github.com/bhilburn/powerlevel9k/wiki)! ### Installation -There are two installation steps to go from a lame terminal to a "Power Level -9000" terminal. Once you are done, you can optionally customize your prompt. +There are two installation steps to go from a vanilla terminal to a PL9k +terminal. Once you are done, you can optionally customize your prompt. [Installation Instructions](https://github.com/bhilburn/powerlevel9k/wiki/Install-Instructions) @@ -71,14 +71,15 @@ variables to your `~/.zshrc`. | Variable | Default Value | Description | |----------|---------------|-------------| |`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt| -|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status history time)`|Segment list for right prompt| +|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt| -So if you wanted to set these variables manually, you would put the following in +The table above shows the default values, so if you wanted to set these +variables manually, you would put the following in your `~/.zshrc`: ```zsh POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) +POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time) ``` #### Available Prompt Segments The segments that are currently available are: From eb67fb5c0c0b504fbbcc6c56433ffe09393dfe7a Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 22 Jan 2017 13:22:33 -0500 Subject: [PATCH 57/59] README: fixing name of `detect-virt` to `detect_virt` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 840ee156..f7a80a09 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ The segments that are currently available are: * [`custom_command`](#custom_command) - Create a custom segment to display the output of an arbitrary command. * [`todo`](http://todotxt.com/) - Shows the number of tasks in your todo.txt tasks file. -* `detect-virt` - Virtualization detection with systemd +* `detect_virt` - Virtualization detection with systemd --------------------------------------------------------------------------------- From a95b4740a6226ed4d1e82305a6f05e59a03ae65e Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 22 Jan 2017 13:22:55 -0500 Subject: [PATCH 58/59] CHANGELOG: Updating to reflect work on `next` --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0fd890..defc1dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ ## next +- Fixed a bug where the tag display was broken on detached HEADs. +- Fixed a bug where SVN detection sometimes failed. +- Fixed the `load` and `ram` segments for BSD. +- Fixed code-points that changed in Awesome fonts. +- Fixed display of "OK_ICON" in `status` segment in non-verbose mode. +- Fixed an issue where dir name truncation that was very short sometimes failed. +- Speed & accuracy improvements to the battery segment. +- Added Github syntax highlighting to README. +- Various documentation cleanup. + +### `vcs` changes + +The VCS segment can now display icons for remote repo hosting services, including Github, Gitlab, and 'other'. + ### `dir` changes Added an option to configure the path separator. If you want something @@ -10,6 +24,18 @@ else than an ordinary slash, you could set This segment will show the usage level of your current partition. +### New segment 'public_ip' added + +Fetches your Public IP (using ident.me) and displays it in your prompt. + +### New segment 'swift_version' added + +This segment displays the version of Swift that is installed / in your path. + +### New segment 'detect_virt' added + +Detects and reports if you are in a virtualized session using `systemd`. + ## v0.5.0 ### `load` and `ram` changes From 7e25fa1e93fbb02e2276e1d245748d09c7c63e8a Mon Sep 17 00:00:00 2001 From: Christian Rebischke Date: Fri, 10 Feb 2017 17:12:05 +0100 Subject: [PATCH 59/59] Added additional ssh identifier for the right statusbar. --- README.md | 1 + powerlevel9k.zsh-theme | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index cd7920e7..82b7ab41 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ The segments that are currently available are: * `swap` - Prints the current swap size. * [`time`](#time) - System time. * [`vi_mode`](#vi_mode)- Your prompt's Vi editing mode (NORMAL|INSERT). +* `SSH` - Additional Identifier for SSH Sessions. **Development Environment Segments:** * [`vcs`](#vcs) - Information about this `git` or `hg` repository (if you are in one). diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1fdedd6b..57d63005 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -670,6 +670,13 @@ prompt_history() { "$1_prompt_segment" "$0" "$2" "244" "$DEFAULT_COLOR" '%h' } +prompt_detect_ssh(){ + local color="yellow" + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + "$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "$color" "ssh" + fi +} + # Detection for virtualization (systemd based systems only) prompt_detect_virt() { if ! command -v systemd-detect-virt;then