Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Custom field widths and wrapping of histdb output #17

Closed
diamond-lizard opened this issue Sep 1, 2017 · 2 comments
Closed

Comments

@diamond-lizard
Copy link

It would be nice if histdb allowed the user to specify the maximum width of each of the fields in histdb's output, and then wrap long lines to fit in to those fields.

Currently, the "column" command through which histdb pipes its output to only wrap once the entire line exceeds the screen width, and the wrapping only happens where the line exceeds the screen width.

This causes really awkward displays of histdb output which contains some really long cwd and/or commands. Just one such long line with, say, a really long cwd, will cause the cmd field to be displayed far to the right with lots of wasted whitespace in between, making visually connecting most of the commands with the cwd's more difficult than it could be if field widths were limited to something narrower.

The other problem is that when the "column" command does wrap, it doesn't keep the wrapping inside the relevant field, but starts prints the excess starting with the left-most column of the next line. This behavior is helpful when one needs to copy the long line using a terminal that can't narrow the selection to just between certain columns on the screen, or where preserving of the original whitespace in the command matters. But it visually messes up the screen and makes it hard to read through lots of histdb output.

All these use cases could be accommodated if there was an option to set field widths to arbitrary values (with perhaps some way of setting a value of "unlimited" for each field -- which appears to be the current default behavior) and wrap properly within those field widths.

@diamond-lizard
Copy link
Author

I'm actually reconsidering this feature request, because its implementation will probably unecessarily bloat-up histdb.

As long as histdb can output its fields with clearly distinguishable separators (which it already does, if you take out the pipe to the "column" command), then it can probably be left up to the user to do further formatting of that output.

So I think it might make more sense to just let the field separator be user-configurable through an option, and have another option to feed the output through the "column" command or not. That would allow histdb to stay lean and yet give the user access to the raw field values to wrap themselves, if they want.

What do you think?

@larkery
Copy link
Owner

larkery commented Sep 1, 2017

Yeah, this is slightly poor UI, but I get the column-ing for free by using column. I don't want to write a width-aware version of column in zsh. Usually if something wraps and I don't want it to, I just pipe it to less or most or similar and scroll right.

I think it would be nice if someone produced a better version of column that could do this job right though.

I'll add some options for separator / column stuff.

@larkery larkery closed this as completed Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants