Oh my Tomtit - alternative to oh my zsh written on Raku
Tags: shell, raku, tools, linux
Published: 2021-08-18 22:19:52

---
title: Oh my Tomtit - alternative to oh my zsh written on Raku
published: true
description: How to create useful utilities using Tomtit
tags: shell, Raku, tools, linux
cover_image: https://raw.githubusercontent.com/melezhik/images/master/tom-set-git.png
---

[Oh My Zsh](https://ohmyz.sh/) is quite poplar ecosystem allows people to run useful scenarios to customize their terminals as well to deal with typical tasks.

A couple years ago I created the [Tomtit](https://github.com/melezhik/Tomtit) and since then this has been bothering me - how similar it is to what ohmyzsh does ...

Well, not exactly, but it's written on Raku.


# Brief comparison with ohmyzsh

* Tomit allows to write portable scripts and execute them to satisfy users' needs. The same what ohmyzsh plugins do

* Unlike ohmyzsh  plugins which are written on Zshell, Tomtit plugins could be written on similar Bash or many [other languages] (https://github.com/melezhik/Sparrow6#supported-languages) supported by Sparrow ( on which the Tomtit is built on )

* Unlike ohmyzsh  scenarios, Tomtit scenarios get run as Raku scripts and thus are highly customizable. In ohmyzsh you only have shell aliases or functions

* Ohmyzh has **275+** plugins which is a little bit more then Sparrow has - [216](http://sparrowhub.io/) plugins, however the difference is not that big, considering that the only Sparrow maintainer is me :-).


# Brief example


Every time I work with `git` I need this helpers that easy my work. With Tomtit I'd do this:

```bash
tom --profile git
```

output:

```
install git@commit ...
install git@git-branch-delete ...
install git@git-publish ...
install git@git-summary ...
install git@pull ...
install git@push ...
install git@set-git ...
install git@status ...
install git@update-branch-list ...
```

And then set-up my git config for _this_ project:

```bash
tom --edit set-git
```

```perl
#!raku

task-run "set git", "git-base", %(
  email => 'melezhik@email.com',
  name  => 'Alexey Melezhik',
  config_scope => 'local',
  set_credential_cache => 'on'
);
```

And apply it:

```bash
tom set-git
```
output:

```
[repository] :: index updated from file:///root/repo/api/v1/index
[set git] :: git credential.helper cache --timeout=3000000
[set git] :: git user.email melezhik@email.com
[set git] :: git user.name Alexey Melezhik
[task check] stdout match <git user.email melezhik@email.com> True
[task check] stdout match <git user.name Alexey Melezhik> True
```

That is it!

Now I only need to commit my configuration into git:

```bash
echo ".cache" >> .gitignore
git add .tom
git commit -a -m "my tomtit helpers for git"
git push
```


# Tomtit profiles

Tomtit profiles are predefined user scripts grouped by categories:


```bash
tom --profile
```

output:

```
ado
azure
git
gitlab
hello
perl
raku
ruby
yaml
```

When you install a profile you install all scripts into `.tom` directory. For example, as we did for git:

```bash
tom --profile --list git
```

output:

```
[profile scenarios]
git@commit      installed: True
git@git-branch-delete   installed: True
git@git-publish installed: True
git@git-summary installed: True
git@pull        installed: True
git@push        installed: True
git@set-git     installed: True
git@status      installed: True
git@update-branch-list  installed: True
```

We've ended up having several `git-*` scripts in `.tom` directory.

Profile scripts are just Raku scripts invoking one or more Sparrow plugins. That's it. Tomtit would generate some reasonable stubs for `.tom/` Raku scripts but you are always free to edit the ones.

For example as we did for `set-git`:

```bash
tom --edit set-git
```

It allows you to generate some boilerplate code but then modify it upon your needs.


# Conclusion

Tomtit and Sparrow could be a reasonable alternative to ohmyzsh with pros mentioned above. Of course, some things like exporting shell aliases won't work with in Tomtit ( but there is workaround for that), however other command line tasks could be executed via Tomtit in very efficient way.

---

I am looking for new (Raku?) contributors for the project.

And thank you for reading.

Alexey.