Hacker News new | past | comments | ask | show | jobs | submit login

haha, had exactly the same thoughts. the colours really makes it much much easier on the eyes to recognise things. well done!



Same thought except, I wonder why this isn’t a patch to xxd?


I'm struggling to even find the canonical source code for xxd, let alone a way to provide a patch. You could probably email the address in the man page, but that's from 1997 so I wouldn't be too optimistic about getting a response. And even then it's quite likely that the original author considers xxd finished and would be reluctant to accept patches for it anyway. On top of all that the hard part of this work (cross-platform terminal colours) had already been done for the author, so the implementation was probably far easier than adding colour output to xxd would have been.


xxd is distributed with Vim.

I've never thought of xxd as being anything but a "Vim thing".

That it had its own history (1990-1998) before being pulled into Vim is a TIL for me.

Here you go:

https://github.com/vim/vim/tree/master/src/xxd

There might still be other versions of this out there, but I suspect most OS distros pick up xxd by way of packaging Vim.

So if you work on some other xxd, you're probably in a dead fork.

The man page is also from Vim:

https://github.com/vim/vim/blob/master/runtime/doc/xxd.1

My first patch to xxd, if I were to work on it, would be to fix the man page to indicate clearly that it's the xxd bundled with Vim.


Cross-platform terminal coloring was solved in the 1980s with termcap and then terminfo, for every terminal that's even come close to seeing mainstream use and which had colors in the first place. The libraries are part of the ncurses library and are shipped with every OS this stuff would build on to begin with.

This also solves the problem of moving the cursor and drawing a screen in general.


Eh, A lot of modern terminal emulators don't seem to bother providing termcap/info entries, or setting their own $TERM variables. In reality, most code just fires off ANSI sequences and hopes for the best. Looking quickly at the source for Hexyl, I think that's what the ansi_term library it uses does.

If anything, I've found doing this works better then trying to muck around with ncurses, which often gets actively mislead by incorrect terminfo entries.


ncurses wins once you use terminals beyond xterm.


Aren't termcap and terminfo linux (or maybe unix) only?


Both of them long predate Linux. They're definitely Unix-flavored, but so's the Berkeley sockets library, and that's available everywhere, too. Ultimately, they're a library which is packaged with a database, and nothing about them is very system-specific except the terminal information in the database.

https://en.wikipedia.org/wiki/Terminfo


termcap was written by Bill Joy in 1978. terminfo dates back to 1982.


termcap is supported on FreeBSD, at the least.


termcap/terminfo styling is limited to features like underline, bold and reverse. No coloring, per se.


"man terminfo | grep color" shows that pretty clearly to not be the case. There's plenty of codes for setting colors.


It's entirely possible termcap and terminfo have been allowing applications to color their output for longer than you've been alive.


The downvotes prove how much HN hates history, I suppose.


Because the author wanted to do his own, personal thing?

I get the idea behind your question, but it irks me a bit since it implies a sort of responsibility to contribute to an existing piece of software. This is a net positive of course, but the beauty of open source is the freedom to work on the things you want to work on.


It's illegible in my terminal. Not a fan of the trend to hardcoded unicorn vomit.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: