Skip to main content

· 2 min read

header

If you use macOS and you are a software engineer, you may know about iTerm already. Well, I won’t mention about how to use iTerm and basic features 😁 . What I want to share is how to automate your iTerm using code.

Let’s imagine you’re developing microservices on your local machine and you want to open iTerm, run all the necessary commands to start services and tail logs. It would be fine for few services, but if you have like more than 5 and you manually click on many keys on keyboard to start them all, you will soon be tired and find it time-consuming.


Let’s dive into how to automate those steps or similar ones on iTerm step-by-step using Python!!!

Install runtime

  • On the top bar, click Scripts > Manage > New Python Script
  • You will be prompted to install Python runtime environment and you should follow to install

Create & run your first script

Once finished, try the 1st step above to create your first Python script

  • iTerm will ask you types of script you want to create a template for you
  • Open your script in any text editor
  • For my example, I will show you how to create scripts that will create new tab and within that tab I split it into 4 panes and echo some texts
  • Once done, save it and head back to iTerm
  • Click on Scripts and you’ll see your script, then click on it

new script

  • You will notice something new on iTerm like the image below. Voila, now you finally have it, new tab with panes without so much effort in typing 😁

final result

Discover more

  • For more available APIs and details, head to official documentation at https://iterm2.com/python-api/
  • The location of scripts can be revealed by heading to Scripts > Manage > Reveal Scripts In Finder

I hope that this post can give you a glimpse of the potential of iTerm and how it can boost your daily work and productivity. Cheers and happy coding!!!

Note: there’s no copyright for any piece of code above and they’re totally open source. Please feel free to copy as your own and modify if needed.

· 4 min read

clean mailbox

After years of professional working experience, I realize 1 thing that I couldn't do back in university: benefits of good email management

You may not care much or don't have time for email management, both your personal and working mailboxes. That's ok I've been through that time and I learned a lesson. In this post I will share with you some tips for making email management easier and benefits of a clean mailbox

Labelling / Categorization

2 popular mailboxes Gmail and outlook both have labelling feature. Whenever you have new mail in inbox you should try to label it to quickly search and filter mail by label later on.

This is how I label my mail:

  • Identify a pattern of mails you've been receiving so far (e.g. Medium newsletter, e-commerce, reminder, job finding)
  • Create label per pattern you identify. Try to use lowercase/Uppercase letter with no space and choose color to easily distinguish (color can be helpful when browsing bunches of emails with different labels).
  • When new email comes, identify the pattern and assign a known label to it
  • If pattern is new or rarely occurs and you don't know which label to assign to, you can either leave it unlabeled or create and assign tbd label to it.

Overall, labelling is great but you will start to get tired when receiving bunches of mail in the morning (for work-related mailbox). You will definitely wonder: how on earth can I simplify or automate this process?

Automation

Mailboxes are smart now. There are features to support you with automated labelling and even many other actions.

Suppose you keep seeing new mails with similar pattern with previous ones, then why not automatically label them whenever they arrive to inbox WITHOUT any manual work? :).

Gmail has feature called Filters, you can setup there.

Besides labelling, there are many other things Filters can do for you such as archive, mark as read and delete.

Mark as important, star email

Yay, automation and labelling may solve many problems. But still there will be important emails that you have to revisit soon to check for info again or reply.

If that's the case then Mark as important and starring (similar to Flag and Pin in Outlook) mail is suitable for this case. I usually have 2 levels of importance: high and medium, and I map them with star and mark as important respectively.

With mailbox's built-in filtering features, you can filter important or starred email in no time. As a result, you will hardly miss or forget them.

Keep Inbox clean

I guess there is only 1 problem left to solve: an Inbox with so many emails displayed on the screen.

Imagine you go to your mailbox and see lots of unread and read emails in inbox, I'm sure you will start to get tired and may not want to check email at all ("been there done that" for me :D ).

The solution for this is to clean up Inbox as much as possible.

  • Most of your mails don't need to stay in Inbox (newsletter, reminder, e-commerce, billing confirmation,...) and you can simply archive them or even delete once you finish reading.
  • Archive is suitable for mail you won't read again but will need it in far future for evidence or verification such as billing
  • Delete works best for read-once mail like advertisement or calendar's event
  • You can keep mails you will follow up in near future (should NOT be over 1 month) in Inbox for quick access and reminding.

In the end, you will have a very clean Inbox with mainly new mails to check out (like my cover photo above taken from my mailboxes)

Extra: leverage keyboard shortcut

As a software engineer, I love keyboard shortcut for faster navigation and action around the mailbox as compared to using mouse. You can do things with keyboard like you do with mouse clicking, but faster.

No one wants to spend lots of time in mailbox and you can simply open, mark as ready, delete, archive,... mail with pressing few buttons. Both Gmail and Outlook offer good keyboard shortcut.

To view list of shortcuts, simply press Shift + ? when opening gmail/outlook

Conclusion

Those are my tips for better email management. It may take time at first but you will be grateful later on ;).