mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-09 02:24:03 +01:00
Merge 9a62004094 into 0f45f82c0a
This commit is contained in:
commit
510e86d0f2
2 changed files with 24 additions and 0 deletions
|
|
@ -21,6 +21,16 @@ RPROMPT='$(toolbox_prompt_info)'
|
||||||
|
|
||||||
In the same way, it adds `toolbox_prompt_name()`, showing the name of the containerized environment.
|
In the same way, it adds `toolbox_prompt_name()`, showing the name of the containerized environment.
|
||||||
|
|
||||||
|
## Hostname customization
|
||||||
|
|
||||||
|
This plugin automatically modifies the `HOST` variable when inside a toolbox container. This enables
|
||||||
|
prompt formats using `%m` to display the toolbox name with the format `toolbx-{name}` instead of just
|
||||||
|
the regular hostname.
|
||||||
|
|
||||||
|
For example, if you're in a toolbox named "dev", your prompt will show `toolbx-dev` instead of just `toolbx` wherever `%m` is used.
|
||||||
|
|
||||||
|
This functionality is enabled by default when loading the plugin and doesn't require any additional configuration.
|
||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command | Description |
|
| Alias | Command | Description |
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,19 @@ function toolbox_prompt_name() {
|
||||||
awk -F\" '/name/ { gsub(/%/, "%%", $2); print $2 }' /run/.containerenv
|
awk -F\" '/name/ { gsub(/%/, "%%", $2); print $2 }' /run/.containerenv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toolbox_prompt() {
|
||||||
|
if [[ -f /run/.containerenv ]]; then
|
||||||
|
local toolbox_name=$(toolbox_prompt_name)
|
||||||
|
if [[ -n "$toolbox_name" ]]; then
|
||||||
|
# Modify the HOST variable to display toolbox name in the prompt
|
||||||
|
# This ensures that '%m' in prompt formats shows "toolbx-{name}" instead of just "toolbx"
|
||||||
|
HOST="toolbx-$toolbox_name"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Modify prompt to include toolbox name when inside a toolbox container
|
||||||
|
toolbox_prompt
|
||||||
|
|
||||||
alias tbe="toolbox enter"
|
alias tbe="toolbox enter"
|
||||||
alias tbr="toolbox run"
|
alias tbr="toolbox run"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue