#ruler #terminal #tmux #ded
I've had this idea of having a ruler in the terminal. Such a ruler would allow me to see how far across the terminal a character or word is.
Why? Not sure yet, I just liked the idea of it. You know, this is one of those solutions looking for a problem. ;). Still, it was fun.
What I came up was this:
(ruler1.png)
This is achieved using tmux, where it's possible to create a split where the output is taken from stdin (rather than spawning a shell):
% ruler | tmux splitw -dI -l2 -b &
Here, this creates a split window two lines high (-l2), puts on the top (-b), and puts the output from the`ruler` command in the window.
Then I can use text using whatever against the ruler to see where on the screen it is.
We can take this a step further though and make use of tmux's `popup-display` command to have a ruler floating on the screen:
(ruler2.png)
... and even make it borderless:
(ruler3.png)
This can be moved using the mouse, by holding Alt down and dragging with mouse-1.
It turns out that using a ruler in an application isn't new.
Thomas Dickey (of #xterm fame) wrote #ded (https://invisible-island.net/ded/ded.html) which has a ruler on it:
(ruler4.png)
#ded is an interesting program of itself and I had to tweak it slightly to make ot use ncursesw to display nicely in tmux (ACS fallback for drawing the ruler), which I might discuss in a separate thread on here.
I'll have to email Thomas to find out what the "workspace ruler" (as it's called) does, and what it's useful for.
As for my ruler, well, I think I have the measure of it now, so I think I'll re-write the quick shell script into something with bells-and-whistles.
Maybe I'll give it conversion options to display inches, feet, cubits, etc... ;)