style(toolbox): use oneliner to extract and quote container name
Diff
1diff --git a/plugins/toolbox/toolbox.plugin.zsh b/plugins/toolbox/toolbox.plugin.zsh
2index b9a594c09661f94dbab697165f873054d891b31d..efe3836f7cde77ed2d624ccecf7594bce65e1b5f 100644
3--- a/plugins/toolbox/toolbox.plugin.zsh
4+++ b/plugins/toolbox/toolbox.plugin.zsh
5@@ -4,8 +4,12 @@ function toolbox_prompt_info() {
6 7 function toolbox_prompt_name() {
8 [[ -f /run/.containerenv ]] || return
9- local _to_print="$(cat /run/.containerenv | awk -F\" '/name/ { print$2 }')"
10- echo ${_to_print:gs/%/%%}
11+
12+ # This command reads the /run/.containerenv file line by line and extracts the
13+ # container name from it by looking for the `name="..."` line, and uses -F\" to
14+ # split the line by double quotes. Then all % characters are replaced with %%
15+ # to escape them for the prompt.
16+ awk -F\" '/name/ { gsub(/%/, "%%", $2); print $2 }' /run/.containerenv
17 }
1819 alias tbe="toolbox enter"