Skip to content

Instantly share code, notes, and snippets.

@mmaeusezahl
Created October 28, 2024 18:22
Show Gist options
  • Save mmaeusezahl/9de899ac9156b09baeb6ca6c52ec9e99 to your computer and use it in GitHub Desktop.
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.
### 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"
@mmaeusezahl
Copy link
Author

Could look like this:

swappy-20241028_193154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment