DEV Community

Cover image for Get the best out of the Macbook Touchbar with iTerm2.
Yoan Malié
Yoan Malié

Posted on

Get the best out of the Macbook Touchbar with iTerm2.

The Touchbar on the Macbook is great. I use it because it's give me useful shortcuts on some apps and I can configure it depending of the application.

We hope that one day we will be able to make a full custom Touchbar with our own buttons, easily. But unfortunally I don't think this feature is planned (Keep on hoping 🤞).

So for this article, let see what we can do in iTerm2 for a better experience with the Touchbar.

At first, I was just trying to make simple shortcuts buttons to launch Git or NPM commands.
So in iTerm2 > Preferences… > Keys, there a button on the bottom right for Add Touch Bar Item. This will open a little popup.

Enter the label you want for the button in the Touchbar, you can add an emoji with ⌘ Command + ^ Control + Space.
For the action, scroll down and select the "Send text" option.
You can now type your command, you have to add a trailing \n to tell iTerm to go back to a new line after sending the command, this will avoid some weird look with your theme.
For a simple git status, the action would be git status\n.

Repeat this step to create as many buttons as you want.

Now, we need to add them to the Touchbar, just go to View > Customize Touch Bar and drag and drop the buttons into the Touchbar.
You maybe need to quit and reload iTerm if you don't see them yet.

And there it is!
The Touchbar with 3 custom buttons ready for Git status, npm install and Composer install
It's cool right 😎?

Top comments (3)

valperignon profile image

Great! Thank you for this tip.

rizwanaslam profile image
Rizwan Aslam

Awesome ❤️

andresreyesdev profile image
Andrés Reyes Galgani

Thank you!