9 ms·
Hexyl: A command-line hex viewer
- codewritinfool 8y agoThis is great. The same author also wrote insect, which is cool, too. https://github.com/sharkdp/insect https://github.com/sharkdp/insect
- EForEndeavour 8y agoVery cool! I greatly appreciate the author's inclusion of a `Pros and cons` section in the README, particularly the cons.
- FrankDixon 8y agoWow! That guy is a monster, so much great stuff
- Twisol 8y agoI admit, my first thought on seeing the title was "What's wrong with xxd?" This is nice! I like the colorization a lot -- it's like with source code, you don't realize how much you rely on the colors until you get a new computer and need to download syntax definitions for your editor again. Only feature I really think is missing is line numbers. Nicely done!
- vectorEQ 8y agohaha, had exactly the same thoughts. the colours really makes it much much easier on the eyes to recognise things. well done!
- joshenders 8y agoSame thought except, I wonder why this isn’t a patch to xxd?
- Sean1708 8y agoI'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.
- msla 8y agoCross-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.
- Sean1708 8y agoAren't termcap and terminfo linux (or maybe unix) only?
- feanaro 8y agotermcap is supported on FreeBSD, at the least.
- msla 8y agoBoth 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 https://en.wikipedia.org/wiki/Terminfo
- ksherlock 8y ago
- kps 8y agoIt's illegible in my terminal. Not a fan of the trend to hardcoded unicorn vomit.
- cygned 8y agoI have to admit, my first question in mind was how to disable colors because I do not use syntax highlighting at all.
- vectorEQ 8y agobut if you want to disable colours in this why not use hexdump or xxd :D . it's like the only feature it adds to standard hexdump tools
- sifoobar 8y agoMe neither. I did use it religiously for a long, long time; then tried without for a week and never went back. It's not like telling the difference between string literals and keywords was ever a major issue for me. I guess it could help short term when learning a new language, but I'm pretty sure it slows down overall progress.
- colordrops 8y agoHow does it slow down progress?
- dublo7 8y agoFor me it doesn't. It's a quick way to see that I made a typo when a keyword doesn't turn the right color, or that I closed a strong with the wrong quote Mark.
- sifoobar 8y agoI find it's a bit like navigating using GPS, once I get there I still have no clue because I was mostly acting on cues. Slow compiles have the same effect for me, I get pushed out of flow and into reactive mode. The only way to write good code is to be proactive, and any features that interfere with that process are worse than whatever "problems" they "solve".
- userbinator 8y agoI'm also not a fan of the colouring, especially in this application, because when you're looking at a hexdump chances are you don't care about ASCII or whitespace --- and it's not as if you couldn't tell whether something is in the ASCII range, given the character representation in the right column anyway. The border lines don't help much either and seem more like decoration; addresses to the left and an indexing header on the top, like the traditional "canonical" hexdump format, would be far more useful.
- hwj 8y agoWhat are line numbers in context of a binary?
- twtw 8y agoAddresses.
- archgoon 8y agoFile offsets; not addresses :) I assume the tool isn't reading ELF format files and working out the memory address.
- Twisol 8y agoRight, I was being a bit loose there. I meant something like how `xxd` displays the number of bytes up to the current output row. Just something to give context of where you are in the file. 00006980: 0000 0000 0000 0000 0000 0000 0000 0000
- msravi 8y agoYou can quickly find position of byte number X using: line number = floor(X/(bytes/line)) + 1 column offset = X % (bytes/line) + 1 Or it could just print byte numbers instead of line numbers.
- kbd 8y ago> I admit, my first thought on seeing the title was "What's wrong with xxd?" My first thought too. Then I looked and saw it was nice, and then I noticed it's by sharkdp. He really has a knack for improving on things you thought were fine (fd and bat being other examples).
- avidal 8y agoLooks like the screenshots on Github are outdated. I just ran it locally and it does print out offsets in a new left-most column. edit: Added in this commit: https://github.com/sharkdp/hexyl/commit/91a119f4537f746045c81e0bdc699e3b95fe7148 https://github.com/sharkdp/hexyl/commit/91a119f4537f746045c8...
- mixmastamyk 8y agoLiked that though the boxes seem to be a distraction. Perhaps they could use the dim ansi code or be turned off.
- deleted 8y ago[deleted]
- pbhjpbhj 8y agoJust looked at manpages on someone else's account with no colour highlighting, definitely missed it.
- cyberferret 8y agoSince back in my DOS programming days, I've lived in several different Hex editors when analysing data streams. Some great, some ordinary. I would have killed for colour highlighting like Hexyl seems to have. I wonder though, whether I can colour code 'blocks' to differentiate them? One of the things I seemed to do a lot in hex editors was to check out the differentiation in, for example, 72 byte blocks of data, so to be able to delineate 72 byte blocks in different colours in the hex editor would make it easier to see where each block starts/ends.
- deleted 8y ago[deleted]
- hwj 8y agoWhile reading this my hope was it not being written in JavaScript. I'm not disappointed ;)
- weavie 8y ago261 lines of pure Rust by the look of it.
- dancek 8y agoI was hoping that it's written in Rust. I wasn't disappointed either.
- ConcernedCoder 8y agoYeah! -- Because prejudice rocks and JavaScript sucks right?
- neysofu 8y agoEvery problem requires appropriate tools. Why would you use a slow and resource-intensive language for a thing as simple as hex viewing?
- pantalaimon 8y agoIt's comparably slow though :p xxd `which hexyl` > /dev/null 0.12s user 0.09s system 99% cpu 0.219 total hexdump `which hexyl` > /dev/null 0.19s user 0.05s system 91% cpu 0.256 total hexyl `which hexyl` > /dev/null 1.69s user 0.39s system 95% cpu 2.175 total
- sgt 8y agoIt takes a second to compute all that color. Nice tool though - but what I would really like to see is a --color argument added to xxd as well, as I'll probably forget about hexyl down the line and start looking for xxd again (which is conveniently already installed on most *nix systems).
- ByronBates 8y agoThe same author also wrote hyperfine, a tool to compare performance of various program runs. hyperfine './target/release/hexyl ./target/release/hexyl' 'xxd ./target/release/hexyl' 'hexdump ./target/release/hexyl' Benchmark #1: ./target/release/hexyl ./target/release/hexyl Time (mean ± σ): 1.529 s ± 0.028 s [User: 1.476 s, System: 0.050 s] Range (min … max): 1.491 s … 1.581 s 10 runs Benchmark #2: xxd ./target/release/hexyl Time (mean ± σ): 70.5 ms ± 0.5 ms [User: 68.0 ms, System: 1.2 ms] Range (min … max): 69.5 ms … 72.3 ms 41 runs Benchmark #3: hexdump ./target/release/hexyl Time (mean ± σ): 262.4 ms ± 2.8 ms [User: 260.1 ms, System: 1.5 ms] Range (min … max): 259.8 ms … 268.8 ms 11 runs Summary 'xxd ./target/release/hexyl' ran 3.72 ± 0.05 times faster than 'hexdump ./target/release/hexyl' 21.70 ± 0.43 times faster than './target/release/hexyl ./target/release/hexyl' Currently hexyl seems nearly 22x slower than xxd.
- miki_rkt 8y agoWhat's wrong with hexdump?
- insertcredit 8y agoIt's not written in Rust.
- sugarraps 8y agoNothing. It's doing fine. Thanks for asking.
- DarkCrusader2 8y agoThe repo author has some pretty interesting rust projects. Worth checking out.
- ape4 8y agoHope this gets into distros
- andrewshadura 8y agoIt will.
- andrewshadura 8y agoe.g. https://tracker.debian.org/pkg/rust-hexyl https://tracker.debian.org/pkg/rust-hexyl
- lsllc 8y agoThe colors remind me of editing MS-DOS files & drive structures with Norton Disk Doctor! Fantastic!
- sashk 8y agoI miss hiew.
- zwischenzug 8y agoI use hexer for this, which is an editor too. http://blog.metaclassofnil.com/?p=757 http://blog.metaclassofnil.com/?p=757 There's also a vim mode for hex, which I use less often: https://vi.stackexchange.com/questions/2232/how-can-i-use-vim-as-a-hex-editor https://vi.stackexchange.com/questions/2232/how-can-i-use-vi...
- Ksi8bb 8y agoOne of the problems with vim+xxd (and many other hex editors) is that it loads the entire file, so you can't easily use it to look at large files (archives, disk images, etc). Many moons ago I wrote a very bare bones ncurses hex viewer/editor, after not really being able to find one that fit my needs. I still use it pretty regularly: https://github.com/quo/hex.py https://github.com/quo/hex.py
- globuous 8y agoThere's hexl-mode for emacs that's pretty cool as well: https://www.gnu.org/software/emacs/manual/html_node/emacs/Editing-Binary-Files.html https://www.gnu.org/software/emacs/manual/html_node/emacs/Ed...
- nickysielicki 8y agoIs anyone aware of a React component that implements a decent hex viewer?
- iso-8859-1 8y agoNeeds a diff mode so that it can also replace vbindiff.
- platz 8y agowhy am i seeing ugly background-colors with rxvt-unicode https://imgur.com/a/qkzAkqR https://imgur.com/a/qkzAkqR instead of the good foreground colors I see in xfce4-terminal https://imgur.com/a/LY6bPn9 https://imgur.com/a/LY6bPn9 i do seem to have 256 colors in urxvt my $TERM is rxvt-256color and i have rxvt-unicode-256color installed
- sharkdp 8y agoPlease see: https://github.com/sharkdp/hexyl/issues/9 https://github.com/sharkdp/hexyl/issues/9
- w4rh4wk5 8y agoHas anyone compared this to dhex, hexer, or ht?
- ausjke 8y agothe author appears to be a true rust master, he wrote quite a few neat programs in rust, very impressive and that actually got me interested in rust lang
- teacpde 8y agoSame here, I like small and neat Rust projects like this, the source code is concise and easy to read. He also authors https://github.com/sharkdp/bat https://github.com/sharkdp/bat, which is also worth to check out.
- ausjke 8y agobat is awesome, I'm using it daily since I found that, better that 'cat'
- Ace_of_Knaves 8y ago261 lines of Rust. Hot damn, I couldn't do it in Python. As someone who is considering learning Rust, this may just have pushed me over the edge.
- xbryanx 8y agoSorry to ask, but what is he use case for a hex viewer like this? What are the kinds of projects you might be working on when you use something like this?
- adamnemecek 8y agoYou come across an undescript binary. It might be a jpeg with an altered extension, malware or basically anything. You open it in a hex viewer and try to gather some info.
- gpm 8y agoYour lab manager goes "hey, can you generate these proprietary binary files (currently made with a horrible gui) to control this robot programmatically".
- ducktective 8y agoBut shouldn't one use an editor, like vim, in those cases?
- gpm 8y agoUh, vim doesn't open binary files very well, and the initial goal is to just display them to figure out how they work not to edit them. Afterwards you will probably want to run experiments with a hex editor, but I found that xxd + vim was better for reading then doing so directly in a hex editor at the time. If I did it again I'd likely start with this because of the color.
- unbendable 8y agoSo i have been working on an embedded project lately where i had to export the framebuffer to an sd Card. I used a raw Format first (netppm) and had to use vim in hex Mode to validate the header. So this is really neat. I was looking for an padding option in the readme but i guess i ll have to install it later
- beatgammit 8y ago
- neuland 8y agoThe colorized output is a nice incremental improvement on xxd. And, I think that it's nice that the README doesn't unnecessarily emphasize that it's written in Rust.
- krylon 8y agoI do not use a hex editor/viewer often. Not at all. But when I do, I am painfully aware of how sparse my toolbelt just became. This little program should fit nicely into that category. An area I would like to explore, but have little-to-none incentives.
- deleted 8y ago[deleted]
- farmerbb 8y agoI've personally found vbindiff excellent for viewing files as hex: https://www.cjmweb.net/vbindiff/ https://www.cjmweb.net/vbindiff/
- heliostatic 8y agoFor something with a little more firepower, I like: https://github.com/evanmiller/hecate https://github.com/evanmiller/hecate
- jbtule 8y agoI wish it would work with less or have less like features, taking the first n bytes is okay, but pretty minimal.
- xvilka 8y agoIt is possible to use also radare2[1] for this, along with radiff2. It provides more options and has zero external dependencies. [1] https://github.com/radare/radare2 https://github.com/radare/radare2
- IWeldMelons 8y agoI guess I am too old, but I use mcview. Or HIEW.
- twic 8y agoOne ludicrous nitpick: the logo doesn't show anything hexyl, that's 1,2,3,5-tetramethylbenzene. If it was a functional group, it might be 3,4,5-trimethylbenzyl or something like that. Hexyl would look like: R \/\/\/
- sharkdp 8y agoThe logo shows a small part of this molecule: https://en.wikipedia.org/wiki/Hexanitrodiphenylamine https://en.wikipedia.org/wiki/Hexanitrodiphenylamine .. which is apparently also called "Hexyl". Granted, I was just looking for a short word that starts with "Hex" and I was never good at organic chemistry :-)
- EamonnMR 8y agoI've been looking for a command line hex editor too.
- pwg 8y agobpe: https://sourceforge.net/projects/bpe/ https://sourceforge.net/projects/bpe/ Or the Joe editor in -hex mode: https://joe-editor.sourceforge.io/ https://joe-editor.sourceforge.io/
- RealityVoid 8y agoWould have loved being able to run it on windows. I use hex viewers for embedded work and have been looking for a decent one for Win.
- sharkdp 8y agoIt works just fine on Windows (you probably need PowerShell for the ANSI escape codes)
- obphuscate 8y agoOk, been a lurker on HN for awhile, but created an account to post. This is freaking awesome. Been looking for something like this for awhile!
- fxfan 8y agoIf I can make a suggestion - I don't mind the program being slow because of all the logic - how would it be if you didn't give special status to ascii but instead tried to intelligently assume a string encoding for strings and accordingly colored "binary" vs "text" (utf-8, utf-16)
- rswail 8y agoCool tool :) having a hex dumper that understood UTF-8 and dumped the characters as one of the columns would be awesome too. These days, ASCII is a small subset of strings.
- sharkdp 8y agoThank you! See: https://github.com/sharkdp/hexyl/issues/6 https://github.com/sharkdp/hexyl/issues/6
- laumars 8y agoJust a minor thing while you're eyeballing this thread: I noticed your fork of lsd has the wrong build instructions. https://github.com/sharkdp/lsd#from-sources https://github.com/sharkdp/lsd#from-sources Good work on these tools though. You make me want to learn Rust :)
- JoachimS 8y agoSlightly off tangent: One tool I have used to dump data (and more) is cxmon. A very nice monitor if one grew up using monitor cartridges on C64, Amiga etc: http://cxmon.cebix.net/ http://cxmon.cebix.net/ https://github.com/cebix/macemu/tree/master/cxmon https://github.com/cebix/macemu/tree/master/cxmon