Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Gat – cat alternative written in Go (github.com/koki-develop)
40 points by koki-develop on April 4, 2023 | hide | past | favorite | 43 comments


Great to have alternatives, but wish there was a “Why” section in readme


Right, does it do things faster? Or somehow more efficiently?

It seems that this is probably slower and consumes far more resources than cat. It also does pretty printing and syntax highlighting. From a Unix standpoint, I would say this is not a cat replacement but a pretty replacement.


I just tried both gat and bat to see if they could really replace cat (spoiler: they cannot — unlike cat they soak up all input before outputting anything, and crash with out of memory very quickly).

A cat alternative would have to handle this correctly:

  $ </dev/zero cat >/dev/null
or it's not really a cat alternative. (Yes, variations on this theme are very useful in scripts and daily shell hacking).


That's wild given that Go makes it harder to read a whole file than read a block at a time.


Here is where the file is read in its entirety. https://github.com/koki-develop/gat/blob/c16dbf999b89b46ed17...


Oh, absolutely not! ioutil.ReadFile and you're done!


At least we know the problem and the solution to it


Wow, I would expect handling streaming properly to be the default case


Similar to https://github.com/sharkdp/bat but Go instead of Rust


A missed opportunity to name it `rat`.


Flying rat > Earthbound rat

Besides, this way I can type 'man bat' and scowl.


Totally off-topic, but: flying rats are so cute. I didn't realize that until we started getting some that would hang in the alcove, above our door, in the summer occasionally. They aren't really a threat either. As long as you don't go out of your way to bug them, they just sleep cozily. The button noses are great.


gat is cat in Catalan: https://lingva.ml/ca/en/gat


What is the terminal or share they use in screenshots at that readme?


Looks like fira code font https://github.com/tonsky/FiraCode and the color scheme is similar to the soft default Alacritty terminal uses https://alacritty.org/


Looks like any terminal with a "▸" as prompt. The rest is the output from bat.


They should have called the tool "gato" (Spanish for "cat")...


"Gat" is catalan for "cat"


and the rust version of cat should have been called "rat" instead of "bat"


The go version could also be called "fat", given the size of go binaries ;)


Both gat and bat seem more like a replacement for less, not cat to me!


I would be curious to see how it compares to similar tools: https://github.com/sharkdp/bat/blob/master/doc/alternatives....


Nitpick about bat: it bothers me that they call it a drop in cat replacement. It is not.

But it's a very useful tool that I use often.

I'm not familiar with ccat but at a quick glance it does not appear to be a drop in cat replacement either.


I’ve been using ccat (colorized cat) for a while, but this looks good too.

https://github.com/owenthereal/ccat



If I read the command `gat myfile` I would definitely assume you were trying to delete it with prejudice.

I would be surprised to see it print to my terminal.

Edit: why downvotes? You can’t use words as commands that invoke a completely different set of connotations than the commands execution does


Given that a `gat` has both an input-side and an output-side, I think it resembles `cat` reasonably well. I'd expect some kind of buffering difference so that the output is "faster" than the input in some way.


Looks like the connotation in your head is really obscure, because the downvoters (I'm guessing), a sibling commenter, and I are wondering why "gat" could mean "delete"?


It's slang, but it is well-known slang (and there's not really some other common meaning).

https://en.wiktionary.org/wiki/gat#Verb


The dictionary definition of "gat" is "revolver", does that really qualify as "obscure"?

Anyways, in terms of usage I've heard, it is almost exclusively implying you'll brandish and/or apply your gun, maybe this part is more obscure, but if I wrote "stab myfile" I don't think you'd expect me to put the contents in a buffer.


What would you expect "wall ~/documents" to do?

I don't really find that command names reliably relate to words. Offhand none of these would do what I expect: curl, top, git, gawk. less is a more featureful more, and who knows what an xxd is. Certainly not a dead four eyed monster with its tongue hanging out.

stab is probably Send To A Buffer, just like grep is Global Regular Expression Print


Well I had to check the dictionary to see what you mean.

"stab" would be obvious, but maybe someone needs to go out and ask 100 or a 1000 people on the street what they think of when they hear the word "gat", and maybe then you can congratulate yourself for being in an exclusive minority.


Perhaps it's not fully mainstreamed, but looking at the current conversation it looks to me like the idea is widespread. Really though, I also see no other other usages of the term online, it surprises me you would not simply type in "gat" to a search engine and easily understand my point.


There's dictionary definition and there's well known usages. In the dictionary "retard" means to slow down or hinder, but if I said "Stop retarding my progress", a "mainstream person" would probably be offended.

Anyway, to end the discussion, I guess the downvotes have other causes, and it'll remain a mystery to both of us.


That’s exactly what I’m saying. There IS no other usage of “gat”, just look online, it exclusively is referring to guns. What kind of counter argument is an incorrect analogy misstating something already spoken?

Wish you had ended it a comment earlier.


I assure you, gat is a common slang, most Americans on the street would be able to tell you that it's a gun.


> "stab" would be obvious

Obviously converts spaces to tabs.


Why delete?


"gat" is slang for "shoot and kill (with a gun)"


I always stay strapped with Gat.


I'll stick to bat


Has anyone made a "cat" like tool that uses treesitter under the hood?


cat -v is ”harmful”

but this is fun, well done!




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

Search: