Visual safety development
Visual warnings when developing on multiple environments
It is common for a developer or sysadmin to have access to multiple environments or servers such as production (live) (server-1), test (staging) and perhaps localhost (server-2).
The problem with this is that it’s easy to forget which environment you’re using.
One solution would be to have a mental pre-check of “am I on server X… yes I am” before running any commands that perform changes (writes/updates). However this is bound to fail you one day.
Another solution is making a visual clue appear which makes it clear consciously or subconsciously which server you’re using.
SQL Server Management Studio (SSMS)
Server 1 connection pane. In this example server-1 is our live production environment.

Server 1 connection options.

Server 2 connection pane. In this example server-2 is our localhost environment.

Server 2 connection options.

Here is the server list on the left. Top one is localhost (server-2) and bottom is live production (server-1).

Running a SQL query against server-1 shows us the nice warning at the bottom.

Running a SQL query against server-2 shows us we’re safe.

Insomnia REST
I use Insomnia which is like Postman for my API testing. I have various environment variables such as URIs which get swapped out based on environment.
Live environment shows red as a warning.

Staging environment shows orange as a warning.

Localhost environment shows green as we’re safe.

Linux SSH
From my .bashrc I deploy on remote servers and local machines.
if [ "$color_prompt" == yes ]; then
if [ ! "$SSH_CLIENT" == "" ]; then
# If this is a ssh session then change our PS1 colour to let them know it's remote.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
# If this isn't a ssh connection then use our normal colour PS1.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
fi
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
Green for local.

Yellow for remote.

Let me know what you think of this article on twitter @M3PGS or leave a comment below!