As software craftsmen, one of the most common things we do on a daily basis is debug our code. When using docker, be it locally or on cloud, a lesser known, yet incredibly powerful tool available to us is docker attach.

Quoting from the docker docs.

Use docker attach to attach your terminal’s standard input, output, and error (or any combination of the three) to a running container using the container’s ID or name. This allows you to view its ongoing output or to control it interactively, as though the commands were running directly in your terminal.

Image for post
Image for post


Most programming languages have debuggers that allow you to halt execution at specific points by defining break points in your program at which point you can inspect the current state of the program. From there you could either go step by step or continue execution until instructed to halt again at some other code path or the program exits. This is a very commonly used approach for debugging your application and allows the developer to be able to inspect the exact state of program at key points to determine if it’s behaving as intended or not. …

The COVID-19 pandemic has forever changed how we work. Even after this nightmare is over, which I am hoping is very soon, it has forever changed how we collaborate with each other.

Image for post
Image for post
My desk setup

I have been predominantly working from home for the last 10 years and have been a huge proponent of it because of 2 main reasons :

  • Avoid wasting hours commuting. While this may not necessarily be the case for most people, and I envy those who have a short commute to work, people living in Bangalore, India, will surely agree to this. You may be living 5 kms away from work and you may still be spending upwards of an hour commuting because of the traffic. …

Image for post
Image for post
Photo by Gregory Culmer on Unsplash

I am a fan of Direnv, however when I wanted to add custom project specific aliases and other helper functions etc, I soon came across There are some good workarounds proposed to address this issue, but none of them felt clean to me. There also exist alternatives that offer similar solutions but why waste time if it can be better spent building something quickly yourself. So I considered rolling out something basic on my own. This is what it looks like :

Dirsh for ZSH

The idea here is fairly straight forward, I can add 2 special files to a project directory, .zshrc.enter and .zshrc.exit and these will get loaded once I enter / leave the directory in zsh shell respectively. This allows me to add project specific custom functions / aliases etc within the .zshrc.enter and clean them up in .zshrc.exit so when I move out from the project directory they are no more cluttering my global configuration. …

It’s convenient to use readily available configuration frameworks, they provide a huge bang for your buck by saving you a lot of time and effort while making your shell experience pretty awesome.

However, this convenience comes at a cost and the more plugins you enable, the more tools you use, they all add up and make ZSH sluggish, especially during start up.

Today I will introduce you to a few tricks I use to measure and profile ZSH. I will also benchmark different setups for their start up times for a comparison.

Image for post
Image for post
Photo by Aron Visuals on Unsplash

NOTE: All scripts I use today are available within my dotfiles/zsh repository. …

By now you know the how powerful SSH is, here I will show you how you can make use of ssh config instead of the command-line flags, to simplify your life. This is especially useful if you use ssh frequently to connect to multiple servers.

Image for post
Image for post
Photo by Maxim Dužij on Unsplash

Quoting from the ssh_config manual :

ssh(1) obtains configuration data from the following sources in the following order:

1. command-line options
2. user’s configuration file (~/.ssh/config)
3. system-wide configuration file (/etc/ssh/ssh_config)

While, it’s perfectly fine supplying all the ssh options via the command line, it’s quite cumbersome and requires an unnecessary amount of typing. As developers, it’s our duty to abhor unnecessary typing and we should feel obligated to automate. …

Quoting SSH man page to remind us all to check them more often.

ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to provide secure encrypted communications between two untrusted hosts over an insecure network.

Most developers spend a considerable amount of their time ssh’d into remote machines, however, few are aware of the power of ssh tunnels or what they even are.

Image for post
Image for post
Photo by Scott Eckersley on Unsplash

SSH Tunneling Primer

SSH Tunneling, is the ability to use ssh to create a bi-directional encrypted network connection between machines over which data can be exchanged, typically TCP/IP. This allows us to easily & securely make services available between machines with minimal effort while at the same time leveraging ssh for user authentication and encryption with little to no overhead. …


Dhruva Sagar

hacker. loves to code, lives inside terminals, vim advocate, open source enthusiast.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store