summaryrefslogtreecommitdiff
path: root/plugins/toolbox/toolbox.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/toolbox/toolbox.plugin.zsh')
-rw-r--r--plugins/toolbox/toolbox.plugin.zsh10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/toolbox/toolbox.plugin.zsh b/plugins/toolbox/toolbox.plugin.zsh
index 377e498cd..efe3836f7 100644
--- a/plugins/toolbox/toolbox.plugin.zsh
+++ b/plugins/toolbox/toolbox.plugin.zsh
@@ -2,5 +2,15 @@ function toolbox_prompt_info() {
[[ -f /run/.toolboxenv ]] && echo "⬢"
}
+function toolbox_prompt_name() {
+ [[ -f /run/.containerenv ]] || return
+
+ # This command reads the /run/.containerenv file line by line and extracts the
+ # container name from it by looking for the `name="..."` line, and uses -F\" to
+ # split the line by double quotes. Then all % characters are replaced with %%
+ # to escape them for the prompt.
+ awk -F\" '/name/ { gsub(/%/, "%%", $2); print $2 }' /run/.containerenv
+}
+
alias tbe="toolbox enter"
alias tbr="toolbox run"