Hacker News new | ask | show | jobs
by Corrado 2307 days ago
I love iTerm2 and have been using it for years. Thanks to this post I've even learned a couple of new things that make me love it even more.

One thing I've been trying to get working in iTerm2 has been AWS profile badges. iTerm2 has the ability to use text "badges"[0] to give feedback about the current environment. I'm an AWS engineer and tend to switch between environments a lot, so I thought it would be great to use the badges functionality to let me know when I was in the production environment vs. say, the development environment. This seems pretty simple but I haven't been able to get it to work.

[0] https://iterm2.com/documentation-badges.html

1 comments

How does your shell know which environment you're in? Is it that you ssh into one environment or another one, and you want the badge to show which one you've connected to?
I cut and paste environment variables into the shell to authenticate to different accounts. Originally, I was trying to trigger an event by looking for specific words (ie. AWS_SECRET_ID) but that didn't seem to work reliably.
If you're switching between envs with cut and paste, maybe you could do likewise with the badge?

   echo -e "\x1B]1337;SetBadgeFormat=$(echo "production" | base64)\007"

   echo -e "\x1B]1337;SetBadgeFormat=$(echo "development" | base64)\007"
Consider giving yourself some bash functions with appropriate names, which set the env vars and switch the badge too. Then instead of pasting each time, you'll just use the function name in the shell.

https://linuxize.com/post/bash-functions/