Update 05.04.2026
This commit is contained in:
@@ -10,7 +10,8 @@ plugins=(... toolbox)
|
||||
|
||||
## Prompt function
|
||||
|
||||
This plugins adds `toolbox_prompt_info()` function. Using it in your prompt, it will show the toolbox indicator ⬢ (if you are running in a toolbox container), and nothing if not.
|
||||
This plugins adds `toolbox_prompt_info()` function. Using it in your prompt, it will show the toolbox
|
||||
indicator ⬢ (if you are running in a toolbox container), and nothing if not.
|
||||
|
||||
You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT` variable:
|
||||
|
||||
@@ -18,8 +19,11 @@ You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT`
|
||||
RPROMPT='$(toolbox_prompt_info)'
|
||||
```
|
||||
|
||||
In the same way, it adds `toolbox_prompt_name()`, showing the name of the containerized environment.
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|----------------------|----------------------------------------|
|
||||
| tb | `toolbox enter` | Enters the toolbox environment |
|
||||
| Alias | Command | Description |
|
||||
| ----- | --------------- | ------------------------------------ |
|
||||
| tbe | `toolbox enter` | Enters the toolbox environment |
|
||||
| tbr | `toolbox run` | Run a command in an existing toolbox |
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
function toolbox_prompt_info() {
|
||||
[[ -f /run/.toolboxenv ]] && echo "⬢"
|
||||
}
|
||||
@@ -2,4 +2,15 @@ function toolbox_prompt_info() {
|
||||
[[ -f /run/.toolboxenv ]] && echo "⬢"
|
||||
}
|
||||
|
||||
alias tb="toolbox enter"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user