1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-09-21 11:00:08 +00:00

added virtualization detection with systemd

This commit is contained in:
Christian Rebischke 2016-12-11 05:16:02 +01:00
parent 1ff9da64d9
commit 881ce33263
No known key found for this signature in database
GPG key ID: D21461E3DFE2060D
2 changed files with 21 additions and 0 deletions

View file

@ -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
---------------------------------------------------------------------------------

View file

@ -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