DEV Community

Cover image for Meet Termit - A NodeJS based terminal editor
Morten Olsrud
Morten Olsrud

Posted on

Meet Termit - A NodeJS based terminal editor

GitHub logo hakash / termit

The TERMinal edITor - embeddable CLI editor

I've finally come around to make some improvements on this project, and as far as I can test, it functions as intended.

Core functionality

Termit is, as the title states, a terminal editor based on NodeJS. This means it is installable with npm i -g termit and runnable from anywhere with termit or termit some-file.txt.

It is heavily influenced by Nano, so some aspects of the user experience is similar, as well as some key-bindings.

If you want a simple terminal editor that simply allows you to edit your files, and the system already has Node installed, then you can use this. It is of course a heavier choice than Nano, Pico, Vim or similar if you install Node for this alone.

Embedding

But wait! There is more!

Termit also supports being embedded in other applications. By simply requiring and instantiating it with voluntary options, you can use this to let the users have a multi-line input area in the CLI that supports copy-paste, returning content on save with or without saving to file.

To support additional actions or content-extraction on save, Termit support pre-save hooks in a similar way that Express uses middleware. You add your callback/middleware to the stack and as with the Express-middlewares, if you do not explicitly call next(), you abort the chain.

This comes in handy if you want to extract the content to the parent application, without letting Termit touch the file-system. Follow the link up-top to the repo to see some simple code-samples for setting this up.

Testers wanted!

Hear ye! Hear ye!

I feel the terminal has reached a level of stability and maturity where it is ready to start testing it in real-world scenarios, and since I am alone on this project, I need the help of the creatively and/or mischievously inclined people here.

First of all mangle it, test it, use it and see if it will break under some weird environments that I won't be able to test myself.

The documentation needs a review as well, and I know the code needs all kinds of testing. I'm planning on implementing testing of the current feature-set, with all the necessary refactoring to achieve that. The reason it's not there already is quite simply time and a need to understand how to test terminal-manipulations. Any tips on that is much appreciated.

Future

Not many plans here yet, besides the testing-bit mentioned further up. I feel I need to get some feedback from actual users on any pain-points or short-comings.

One thing I know I want to investigate, is "compiling" is as a standalone package installable via Chocolatey, Homebrew or similar. The compiling would remove the need for NodeJS to be pre-installed, but I fell that it would never compete with Nano or similar, so I might not bother.

The embeddable aspect is possibly the most interesting feature, and the direction that would benefit most from gaining more features and making it more useful to other projects as the core editor.

The End

Well, thanks for your time, and your help! I hope you like it, even if you don't see the point of it. It was an interesting challenge really.

Use the comments below to express first-impressions and general comments, and if you have any issues with it, please open an issue on GitHub. PR's are of course welcome as well.

Cheers!

-Morten

Top comments (2)

Collapse
 
yavorski profile image
Yavorski

Why picking the name of already existing terminal?

github.com/thestinger/termite

Collapse
 
hakash profile image
Morten Olsrud

I can see that it can be confusing with the similar name. Did not know about Termite, but there is a slight difference in the name. Termit != Termite. Also, Termit is an editor like Nano, not an entire terminal as it seems that Termite is.

Thank you for your feedback!