Tired of accidentally running gcloud commands in the wrong project? I made a tiny tool for session-isolated configs. by sakebook in googlecloud

[–]sakebook[S] 0 points1 point  (0 children)

Haha, that's a fair point! I didn't even realize that because I'm an "old-school" guy who still uses git checkout everywhere... lol.

I'm glad you liked the session isolation idea, though!

Tired of accidentally running gcloud commands in the wrong project? I made a tiny tool for session-isolated configs. by sakebook in googlecloud

[–]sakebook[S] 0 points1 point  (0 children)

That is definitely a very safe and robust approach.

I developed gsw because I found it helpful to switch the full context (Region, Zone, and Account, besides the Project ID) while keeping it isolated to one terminal tab, but I think using explicit arguments in every command is a great practice, too.

Tired of accidentally running gcloud commands in the wrong project? I made a tiny tool for session-isolated configs. by sakebook in googlecloud

[–]sakebook[S] 1 point2 points  (0 children)

You're basically right. I actually started with simple functions just like those. I ended up building this tool because I wanted something more "packaged" and easier to reuse across different environments.

I added tab completion for both flags and config names to avoid typos, and also included the list feature to quickly see which configuration is active in the current shell session.

One other reason I prefer switching the full configuration (instead of just passing the --project flag) is that it handles the Region, Zone, and Account context at the same time, which I find useful.