diff --git a/CHANGELOG.md b/CHANGELOG.md index 8060e0fa..defc1dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,41 @@ ## 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 else than an ordinary slash, you could set `POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. +### New segment 'disk_usage' added + +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 diff --git a/README.md b/README.md index f6b8c54c..f7a80a09 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: @@ -88,6 +89,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. +* [`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. @@ -137,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 --------------------------------------------------------------------------------- @@ -306,6 +308,16 @@ If you want to customize the directory separator, you could set: POWERLEVEL9K_DIR_PATH_SEPARATOR="%f "$'\uE0B1'" %F" ``` +##### disk_usage + +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_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 This segment tries to examine all currently used network interfaces and prints diff --git a/functions/icons.zsh b/functions/icons.zsh index c02e84e8..1d37ba60 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' #  + DISK_ICON $'\uE1AE ' #  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' # 🔋 + DISK_ICON $'\uF0A0 ' #  OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' @@ -212,6 +214,7 @@ case $POWERLEVEL9K_MODE in TEST_ICON '' TODO_ICON $'\u2611' # ☑ BATTERY_ICON $'\U1F50B' # 🔋 + DISK_ICON $'hdd ' OK_ICON $'\u2713' # ✓ FAIL_ICON $'\u2718' # ✘ SYMFONY_ICON 'SF' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c3f2be74..f104b789 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -337,6 +337,48 @@ prompt_background_jobs() { fi } +# Segment that indicates usage level of current partition. +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=( + 'normal' 'yellow' + 'warning' "$DEFAULT_COLOR" + 'critical' 'white' + ) + typeset -AH hdd_usage_backcolors + hdd_usage_backcolors=( + 'normal' $DEFAULT_COLOR + 'warning' 'yellow' + 'critical' 'red' + ) + + local disk_usage="${$(\df -P . | sed -n '2p' | awk '{ print $5 }')%%\%}" + + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL" ]; then + current_state='warning' + if [ "$disk_usage" -ge "$POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL" ]; then + current_state='critical' + fi + else + if [[ "$POWERLEVEL9K_DISK_USAGE_ONLY_WARNING" == true ]]; then + current_state='' + return + fi + current_state='normal' + fi + + local message="${disk_usage}%%" + + # Draw the prompt_segment + 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 +} + prompt_battery() { # The battery can have four different states - default to 'unknown'. local current_state='unknown' @@ -1065,12 +1107,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' }