Live data from Hacker News

Bat v0.26.0

github.com

31–40 of 78 posts

Re: Bat v0.26.0

#31

The `--pager=builtin` change is interesting; first time I've heard of minus. > Traditional pagers like more or less weren't made for integrating into other applications. They were meant to be standalone binaries that are executed directly by users. However most applications don't adhere to this and exploit these pagers' functionality by calling them as external programs and passing the data through the standard input…

Having to pipe to a pager - to follow the unix philosophy - means: - extra typing each time - the pager receives static output. There is no interactivity... Sure, most pagers can search. But there is no way to have a table with adjustable columns, or toggle word wrap or line numbers etc.

I feel that for a tool like bat, it is better to have it built-in and not follow the composable philosophy because it is just so much more convenient. Of course the minus integration in bat is fairly basic at the moment, I guess supporting different code paths for static pagers vs interactive would increase maintenance burden quite a lot...

Re: Bat v0.26.0

#32

The `--pager=builtin` change is interesting; first time I've heard of minus. > Traditional pagers like more or less weren't made for integrating into other applications. They were meant to be standalone binaries that are executed directly by users. However most applications don't adhere to this and exploit these pagers' functionality by calling them as external programs and passing the data through the standard input…

Most Unix CLI tools don't respect the unix philosophy anyway. For example a lot support something like `--output file.txt` when the Unix philosophy would say to not implement that and just use `>> file.txt`

From my experience, --output is a minority in my workflow. Which tools do you use need --output?

Re: Bat v0.26.0

#33

The `--pager=builtin` change is interesting; first time I've heard of minus. > Traditional pagers like more or less weren't made for integrating into other applications. They were meant to be standalone binaries that are executed directly by users. However most applications don't adhere to this and exploit these pagers' functionality by calling them as external programs and passing the data through the standard input…

Most Unix CLI tools don't respect the unix philosophy anyway. For example a lot support something like `--output file.txt` when the Unix philosophy would say to not implement that and just use `>> file.txt`

I think practical Unix philosophy is more nuanced. There are filter programs that read STDIN and write to STDOUT per default.

But this is not really practical for many use cases which are not filters first and foremost. So we end up with still reading from STDIN or the list of files presented as arguments. We write to the file given by -o (or --output) which can be "-" to signify STDOUT.

I find this pattern very flexible because it allows multiple input files or STDIN and a single output file which can be STOUT, so you still get your filtering behaviour if you want.

(For completeness sake, there is a third pattern somewhat prevalent. In call these copy type programs. They treat the last argument specially, usually as some form of target, like `cp a b c target`.)

Re: Bat v0.26.0

#34
post #8
post #3

What is it? It says it is a cat clone, but what is cat?

A very wide used command line program that prints out the contents of a file on a terminal. Chances are pretty high cat is installed on your system already. Example: If you're navigating to the folder of a git repository in your terminal and quickly want to see what the readme says without having to open a file manager or going to the website on github/gitlab/codeberg you can run: cat README.md Which shows the text s…

It doesn't do that actually. It concatenates files. From the description on the man page:

    Concatenate FILE(s) to standard output.

    With no FILE, or when FILE is -, read standard input
https://man7.org/linux/man-pages/man1/cat.1.html

Re: Bat v0.26.0

#35

Earlier quoted context omitted.

Most Unix CLI tools don't respect the unix philosophy anyway. For example a lot support something like `--output file.txt` when the Unix philosophy would say to not implement that and just use `>> file.txt`

From my experience, --output is a minority in my workflow. Which tools do you use need --output?

Coincidentally, I went looking for some the other day and there were very few. Everything that uses --output for this purpose, that I could find, was a compiler.

Re: Bat v0.26.0

#36

Earlier quoted context omitted.

Most Unix CLI tools don't respect the unix philosophy anyway. For example a lot support something like `--output file.txt` when the Unix philosophy would say to not implement that and just use `>> file.txt`

I think practical Unix philosophy is more nuanced. There are filter programs that read STDIN and write to STDOUT per default. But this is not really practical for many use cases which are not filters first and foremost. So we end up with still reading from STDIN or the list of files presented as arguments. We write to the file given by -o (or --output) which can be "-" to signify STDOUT. I find this pattern very flex…

--output was just one example. Many tools provide formatting options, ls can sort, find can delete files it finds, and so on.

Re: Bat v0.26.0

#37

Earlier quoted context omitted.

Most Unix CLI tools don't respect the unix philosophy anyway. For example a lot support something like `--output file.txt` when the Unix philosophy would say to not implement that and just use `>> file.txt`

From my experience, --output is a minority in my workflow. Which tools do you use need --output?

dd an company require if= and of=, if that counts

Re: Bat v0.26.0

#38

Earlier quoted context omitted.

Along with bat, these are my main ones that I install always: fd, a better find: https://github.com/sharkdp/fd ripgrep (rg) a modern grep: https://github.com/BurntSushi/ripgrep eza for ls replacement: https://github.com/eza-community/eza duf is a cleaner df: https://github.com/muesli/duf dust for du: https://github.com/bootandy/dust Also fish + starship + yazi + helix, all of which mostly work perfectly with the defa…

What is helix? Haven't heard of it before, I don't think.

Helix is a Vim/Kakoune-inspired modal editor, with a bunch of stuff built in by default. For example it has support for a huge amount of LSPs and intergrates them automatically.

It's command structure is also super similar to Vim's, but, basically, "flipped" around. So you wouldn't write "dw" to delete a word, but "wd". This means that you can see whatever you're selecting to be deleted highlighted before you actually execute the deletion. It has a bunch of saner commands also for stuff people usually want to do, like go to definition/usage, and honestly for people who aren't Vim-addicts such as myself, it's probably a good idea to check it out once, to see if it's a good fit for you.

Re: Bat v0.26.0

#39

Earlier quoted context omitted.

I think practical Unix philosophy is more nuanced. There are filter programs that read STDIN and write to STDOUT per default. But this is not really practical for many use cases which are not filters first and foremost. So we end up with still reading from STDIN or the list of files presented as arguments. We write to the file given by -o (or --output) which can be "-" to signify STDOUT. I find this pattern very flex…

--output was just one example. Many tools provide formatting options, ls can sort, find can delete files it finds, and so on.

I don't believe programs able to sort their output is acting against the UNIX philosophy. "ls" lists files and does a good job of it. find's -exec is a bit stretching it (-delete came later IIRC), but generally it adheres the philosophy pretty well.

From my experience of programming small utilities for myself, UNIX philosophy says "a tool handles a single job and handles it well" is a nod to fallacy of "gluing" things together.

Because when you start to glue things beyond simple pipes, the glue code becomes exponentially complex and takes more and more of the program, which creates a maintenance hell and affects performance (much more profoundly on a PDP).

So, simple tools doing single things is both easier to write and maintain, and they're much more performant in general.

Remember the guy who left a whole Hadoop cluster in the dust with GNU command line tools and some pipes, on a small laptop.

Re: Bat v0.26.0

#40

Earlier quoted context omitted.

From my experience, --output is a minority in my workflow. Which tools do you use need --output?

dd an company require if= and of=, if that counts

dd doesn't require either if= or of=. It'll read from stdin (or pipe) if you omit if= and it'll write to stdout happily if you omit of=.

From the man page:

    if=FILE - read from FILE instead of stdin.
    of=FILE -  write to FILE instead of stdout.
So you can do:

   cat x.iso | dd oflag=direct bs=4096kB | /dev/sdc
Post reply on HN