Created
October 28, 2024 18:22
-
-
Save mmaeusezahl/9de899ac9156b09baeb6ca6c52ec9e99 to your computer and use it in GitHub Desktop.
A simple custom command for starship to detect if a shell is in a distrobox container.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### use it in your starship.toml | |
# in the top include it in your main format using ${custom.distrobox} (with brackets) | |
# format = " .... ${custom.distrobox} ..." | |
[custom.distrobox] | |
description = "Displays name of the activated distrobox container" | |
# box symbol from NerdFonts | |
symbol = " " | |
# activates when the command in "when" returns 0 (succeed / true) | |
# we check for the $CONTAINER_ID variable as described in https://github.com/89luca89/distrobox/blob/main/docs/useful_tips.md#detect-if-youre-in-a-distrobox | |
when = "[[ ! -z \"${CONTAINER_ID}\" ]]" | |
# the output of this command will be provided in $output for the format | |
# here we get the name of the distrobox | |
command = "echo ${CONTAINER_ID}" | |
# format in the shell | |
format = "[ $symbol $output ]($style)" | |
disabled = false | |
# apply your favorite style here... | |
style = "bold green" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could look like this: