DEV Community

Cover image for Oh my Tomtit - alternative to oh my zsh written on Raku
Alexey Melezhik
Alexey Melezhik

Posted on

Oh my Tomtit - alternative to oh my zsh written on Raku

Oh My Zsh 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 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 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 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:

tom --profile git
Enter fullscreen mode Exit fullscreen mode

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 ...
Enter fullscreen mode Exit fullscreen mode

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

tom --edit set-git
Enter fullscreen mode Exit fullscreen mode
#!raku

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

And apply it:

tom set-git
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

That is it!

Now I only need to commit my configuration into git:

echo ".cache" >> .gitignore
git add .tom
git commit -a -m "my tomtit helpers for git"
git push
Enter fullscreen mode Exit fullscreen mode

Tomtit profiles

Tomtit profiles are predefined user scripts grouped by categories:

tom --profile
Enter fullscreen mode Exit fullscreen mode

output:

ado
azure
git
gitlab
hello
perl
raku
ruby
yaml
Enter fullscreen mode Exit fullscreen mode

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

tom --profile --list git
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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:

tom --edit set-git
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (3)

Collapse
 
massa0000 profile image
Massa 👽 Humberto

Can you elaborate on the "but there is workaround for that"?

Collapse
 
melezhik profile image
Alexey Melezhik • Edited

Also there is Sparrow Raku Tasks thing - github.com/melezhik/Sparrow6/blob/... - that allows a user maintain globally defined tasks ( the one can access from any directory ) - could a reasonable alternative to aliases. One just need to keeps tasks lists within Git repo or we can create a tomtit tasks that would deploy rake tasks into users's home , that's it ... So as you can see Sparrow/Tomtit provides a lot of ways to achieve things ...

Collapse
 
melezhik profile image
Alexey Melezhik • Edited

| Of course, some things like exporting shell aliases won't work with in Tomtit ( but there is workaround for that)

Honestly I forgot what I meant 😂. However I would say that it's possible to create a tomtit task that would generate all shell/bash aliases ( as a shell script) for shell lovers, and then it just needs to be sourced into current user session - which is extra step (oh my zh seems takes care about that out of the box )