Terminal "badge" like function similar to iTerm2 #18553

Open
opened 2026-01-31 06:17:31 +00:00 by claunia · 2 comments
Owner

Originally created by @ConercaoAlpha on GitHub (Sep 27, 2022).

Description of the new feature/enhancement

Something akin to the "badge" functionality in iTerm2. This creates a configurable "badge" in the background of a terminal that can be used to denote whatever is wished. I personally use this feature when working with multiple cloud environments to differentiate between the different terminals

Proposed technical implementation details (optional)

As for how to implement this, I am unsure but perhaps they could be added as a function to Terminal's improving theming?
At present this feature is called from a function within my .zshrc file(below)

set_badge () {
printf "\033]1337:SetBadgeFormat=%s\007" $(echo $1 | base64)

This can then be set by using

set_badge $VAR

or

set_badge "something with whitespace"

Example
Screenshot 2022-09-27 at 14 55 26

Originally created by @ConercaoAlpha on GitHub (Sep 27, 2022). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Something akin to the "badge" functionality in iTerm2. This creates a configurable "badge" in the background of a terminal that can be used to denote whatever is wished. I personally use this feature when working with multiple cloud environments to differentiate between the different terminals # Proposed technical implementation details (optional) As for how to implement this, I am unsure but perhaps they could be added as a function to Terminal's improving theming? At present this feature is called from a function within my .zshrc file(below) ``` set_badge () { printf "\033]1337:SetBadgeFormat=%s\007" $(echo $1 | base64) ``` This can then be set by using ``` set_badge $VAR ``` or ``` set_badge "something with whitespace" ``` Example <img width="2048" alt="Screenshot 2022-09-27 at 14 55 26" src="https://user-images.githubusercontent.com/37657888/192548252-dbf028ba-d339-4ac1-be50-200dde07a0d9.png">
claunia added the Issue-FeatureArea-VTProduct-Terminal labels 2026-01-31 06:17:31 +00:00
Author
Owner

@ConercaoAlpha commented on GitHub (Apr 19, 2023):

I've managed to get a workaround for this working using a couple of zsh functions that replace the background image file path in the json.settings.

init_background () {

cd /mnt/c/Users/$(whoami)/AppData/Local/Packages/Microsoft.WindowsTerminal_xxxxxxxxxxxx/LocalState/
jpg=$(grep .jpg settings.json | cut -d "\\" -f 9 | awk '{sub(/..$/,"")}1')

if [ "$jpg" != "blank.jpg" ];
then
  sed -i "s|$jpg|blank.jpg|" settings.json
fi

cd $OLDPWD
}

#Run init_background on login to clear terminal
init_background

set_background () {

cd /mnt/c/Users/$(whoami)/AppData/Local/Packages/Microsoft.WindowsTerminal_xxxxxxxxxxxx/LocalState/
jpg=$(grep .jpg settings.json | cut -d "\\" -f 9 | awk '{sub(/..$/,"")}1')

case ${jpg} in
  blank.jpg)
    sed -i "s|blank.jpg|$ENV_PROFILE.jpg|" settings.json
    ;;
  environment1.jpg)
    sed -i "s|environment1.jpg|$ENV_PROFILE.jpg|" settings.json
    ;;
  environment2.jpg)
    sed -i "s|environment2.jpg|$ENV_PROFILE.jpg|" settings.json
    ;;
  environment3.jpg)
    sed -i "s|environment3.jpg|$ENV_PROFILE.jpg|" settings.json
    ;;
  environment4.jpg)
    sed -i "s|environment24.jpg|$ENV_PROFILE.jpg|" settings.json
    ;;
  environment5.jpg)
    sed -i "s|environment5.jpg|$ENV_PROFILE.jpg|" settings.json
esac

cd $OLDPWD
}

The init_background function sets the background to blank (assuming that the background has been set before). This could probably go into z.logout to clear the profile on close. The second function, set-background allows for chopping and changing between environments. This is doing the same function as setting the badge variable in iTerm2.

Both functions require that you have created a "blank" background image and then one for each of your environments, LIVE, STAGING. DEV/TEST etc etc

@ConercaoAlpha commented on GitHub (Apr 19, 2023): I've managed to get a workaround for this working using a couple of zsh functions that replace the background image file path in the `json.settings`. ``` init_background () { cd /mnt/c/Users/$(whoami)/AppData/Local/Packages/Microsoft.WindowsTerminal_xxxxxxxxxxxx/LocalState/ jpg=$(grep .jpg settings.json | cut -d "\\" -f 9 | awk '{sub(/..$/,"")}1') if [ "$jpg" != "blank.jpg" ]; then sed -i "s|$jpg|blank.jpg|" settings.json fi cd $OLDPWD } #Run init_background on login to clear terminal init_background set_background () { cd /mnt/c/Users/$(whoami)/AppData/Local/Packages/Microsoft.WindowsTerminal_xxxxxxxxxxxx/LocalState/ jpg=$(grep .jpg settings.json | cut -d "\\" -f 9 | awk '{sub(/..$/,"")}1') case ${jpg} in blank.jpg) sed -i "s|blank.jpg|$ENV_PROFILE.jpg|" settings.json ;; environment1.jpg) sed -i "s|environment1.jpg|$ENV_PROFILE.jpg|" settings.json ;; environment2.jpg) sed -i "s|environment2.jpg|$ENV_PROFILE.jpg|" settings.json ;; environment3.jpg) sed -i "s|environment3.jpg|$ENV_PROFILE.jpg|" settings.json ;; environment4.jpg) sed -i "s|environment24.jpg|$ENV_PROFILE.jpg|" settings.json ;; environment5.jpg) sed -i "s|environment5.jpg|$ENV_PROFILE.jpg|" settings.json esac cd $OLDPWD } ``` The `init_background` function sets the background to blank (assuming that the background has been set before). This could probably go into `z.logout` to clear the profile on close. The second function, `set-background` allows for chopping and changing between environments. This is doing the same function as setting the badge variable in iTerm2. Both functions require that you have created a "blank" background image and then one for each of your environments, LIVE, STAGING. DEV/TEST etc etc
Author
Owner

@83nf15h commented on GitHub (Mar 1, 2025):

It would be excellent to implement it similar to iterm2 where it can pull a variable to display like the current system you are connected to. Using an image is a good workaround when there are a couple of systems but when there a many different systems being able to use a text variable would be very helpful.

@83nf15h commented on GitHub (Mar 1, 2025): It would be excellent to implement it similar to iterm2 where it can pull a variable to display like the current system you are connected to. Using an image is a good workaround when there are a couple of systems but when there a many different systems being able to use a text variable would be very helpful.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18553