mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
Merge branch 'detect-virt' into detect-virt-next
This commit is contained in:
commit
c42a77ae60
2 changed files with 28 additions and 7 deletions
|
@ -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
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ else
|
|||
POWERLEVEL9K_INSTALLATION_PATH="$0"
|
||||
fi
|
||||
|
||||
# Resolve the instllation path
|
||||
# Resolve the installation path
|
||||
if [[ -L "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
|
||||
# If this theme is sourced as a symlink, we need to locate the real URL
|
||||
filename="$(realpath -P $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || readlink -f $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null || perl -MCwd=abs_path -le 'print abs_path readlink(shift);' $POWERLEVEL9K_INSTALLATION_PATH 2>/dev/null)"
|
||||
|
@ -106,7 +106,7 @@ fi
|
|||
# name. From this function name, we strip the "prompt_"-prefix and
|
||||
# uppercase it. This is then prefixed with "POWERLEVEL9K_" and suffixed
|
||||
# with either "_BACKGROUND" or "_FOREGROUND", thus giving us the variable
|
||||
# name. So each new segment is user-overwritable by a variable following
|
||||
# name. So each new segment is user-overwritten by a variable following
|
||||
# this naming convention.
|
||||
################################################################
|
||||
|
||||
|
@ -117,7 +117,7 @@ CURRENT_BG='NONE'
|
|||
|
||||
# Begin a left prompt segment
|
||||
# Takes four arguments:
|
||||
# * $1: Name of the function that was orginally invoked (mandatory).
|
||||
# * $1: Name of the function that was originally invoked (mandatory).
|
||||
# Necessary, to make the dynamic color-overwrite mechanism work.
|
||||
# * $2: The array index of the current segment
|
||||
# * $3: Background color
|
||||
|
@ -207,7 +207,7 @@ CURRENT_RIGHT_BG='NONE'
|
|||
|
||||
# Begin a right prompt segment
|
||||
# Takes four arguments:
|
||||
# * $1: Name of the function that was orginally invoked (mandatory).
|
||||
# * $1: Name of the function that was originally invoked (mandatory).
|
||||
# Necessary, to make the dynamic color-overwrite mechanism work.
|
||||
# * $2: The array index of the current segment
|
||||
# * $3: Background color
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue