Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have two strings "foo" and "bar" and I want them displayed in dzen2 like this:

[foo         bar]

is it possible to do this without using the -ta option at all, just positioning commands?

share|improve this question
up vote 2 down vote accepted

Yes, but it does require knowledge of the width of 1 char in that font, and the length of text you want to align. To float something left, you would need to use:


Where n is the number of chars in "sometext" and k is the pixel width of one char.

Dzen does come with a program, textwidth for calculating the size of non-monospace fonts, in chich case [n*k] would be replaced by that value.

I would recommend using a native version of the code if you can for efficiency, I have a version for golang here, but if this is not possible you can just run the textwidth command.

SVN revision 255 of dzen apparently contains a ^ba(width, align) command, see the wiki.

share|improve this answer
So, this only applies for scenarios when a monospace font is being used? – AnonymousLurker Aug 17 '12 at 6:42
Or when you can calculate the width of the non-monospace font. – Mike Cooper Sep 20 '12 at 2:22
I should have mentioned that dzen does come with a program for calculating the width of non-monospace fonts, I'll add it to the answer. – user1034533 Oct 26 '12 at 9:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .