Automating the startup of a dev workflow
Tags: automation, tooling, workflow, beginners
Published: 2024-01-02 19:09:39

Hopefully, this is the first of many small posts showing how I automate my workflow.

Back around 2008, I had a mentor/buddy for my new job. Rys. He was a wonderful, knowledgeable, and supportive buddy who always seemed to be one step ahead.

One day he noticed that I came into the office each day, opened the terminal, and created x amount of tabs, which I then named (So I knew what each terminal was there for, e.g. logs, database, git, and codebases etc).

He asked me:

> How much time would you save if you could automate that?

Sitting there, stunned, I wasn't sure how to do what he said, but that question has stuck with me throughout my career. Then over the years, I've started to automate more and more, because I would remember Rys asking me how much time I would save.

So, I now have an alias defined as follows:

```shell
start-company() {
  open -a Music
  open -a Slack
  open -a "Google Chrome"
  open -a Obsidian
  open -a Notion
  open -a Miro
  open -a "Visual Studio Code"
}
```

Where `company` is the name of the company I work for. This may seem small, and maybe even obvious, but running `start-company` each time I boot my machine is substantially quicker than opening each application in turn.

Running this command is the first of many stacked habits I have in the morning. For more information on stacking habits, check out [Atomic Habits](https://jamesclear.com/atomic-habits). I'm hopefully going to write up other habits I have for my workflow.

So I have my terminal and other applications open, but how about naming those darn terminal windows Rys asked me about all those years ago?

Well, I now use [tmux](https://github.com/tmux/tmux) and [tmuxinator](https://github.com/tmuxinator/tmuxinator). I have had many failed `tmux` attempts over the years, but I'm firmly bedded in now.

What is `tmux`?

> tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

That nicely brings us to `tmuxinator`:

> Create and manage tmux sessions easily.

Therefore I can start a `tmux` session, via `tmuxinator`, which has a defined configuration. So one example would be:

```text
name: dotfiles
root: ~/

windows:
  - bms: cd ~/git/github/benmatselby
  - work: cd ~/git/github/[company-name]
  - dotfiles: cd ~/git/github/benmatselby/dotfiles
  - life: cd ~/git/github/benmatselby/life
```

When I now run `tmuxinator start dotfiles` (I have this aliased to `txs`), I get 4 named windows/tabs in a `tmux` session, all in the correct working directory. This is a massive time saving for me. I have many `tmuxinator` configuration files now. Each project generally gets its own configuration.

Hopefully, this setup is useful, or maybe interesting to you. Happy automating folks 😊

Photo by <a href="https://unsplash.com/@sortino?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Joshua Sortino</a> on <a href="https://unsplash.com/photos/worms-eye-view-photography-of-ceiling-LqKhnDzSF-8?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>

---

### See also

- [My dotfiles](https://github.com/benmatselby/dotfiles)
- [Setting up k9s skins for different Kubernetes clusters](https://benmatselby.dev/post/2023/setting-up-k9s-skins-for-environments/)