diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2016-12-21 01:51:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-21 01:51:02 +0300 |
commit | 52d95f9038c9733476e06fd105f82f3bcf440643 (patch) | |
tree | 4e293766e2ecc49c6c9c25d3fc31167dd8b96938 | |
parent | 7a49c9704dbbb0f1be1f9314410f41bcfd859d5e (diff) | |
parent | c42a77ae60455df5c74dde47586a6e4a528f587c (diff) |
Merge pull request #362 from shibumi/detect-virt-next
Added segment for virtualization detection.
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | powerlevel9k.zsh-theme | 20 |
2 files changed, 21 insertions, 0 deletions
@@ -136,6 +136,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 d574e3b5..cdace7fa 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -547,6 +547,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" "$DEFAULT_COLOR" "$virt" + else + ; + fi + else + "$1_prompt_segment" "$0" "$2" "$color" "$DEFAULT_COLOR" "$virt" + fi +} + + prompt_icons_test() { for key in ${(@k)icons}; do # The lower color spectrum in ZSH makes big steps. Choosing |