From 3e5f0cfd1cb3302237aade880d292fd9a6f9a08f Mon Sep 17 00:00:00 2001 From: Daniel Carrillo Date: Tue, 4 Jan 2022 15:37:40 +0100 Subject: [PATCH] [p10k] Add hcloud prompt --- .p10k.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.p10k.zsh b/.p10k.zsh index 0b6728a..7ec97af 100644 --- a/.p10k.zsh +++ b/.p10k.zsh @@ -101,6 +101,7 @@ # battery # internal battery # wifi # wifi speed # example # example user-defined segment (see prompt_example function below) + hcloud ) # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. @@ -1526,6 +1527,19 @@ # Custom prefix. # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' + typeset -g POWERLEVEL9K_HCLOUD_SHOW_ON_COMMAND='hcloud' + typeset -g POWERLEVEL9K_HCLOUD_FOREGROUND=214 + function prompt_hcloud() { + hcloud_file="$HOME/.config/hcloud/cli.toml" + if [ -f $hcloud_file ] ; then + context=$(fgrep active_context $hcloud_file | cut -f 2 -d "=" | tr -d " \"") + p10k segment -f 208 -i '' -t "$context" + fi + } + function instant_prompt_hcloud() { + prompt_hcloud + } + # Example of a user-defined prompt segment. Function prompt_example will be called on every # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user.