Hacker News new | past | comments | ask | show | jobs | submit | dyanaraps's comments login

Thanks, I'm glad you find it useful!


Useless use of `cat`. :)

    wc -l file
To hide filename:

    wc -l < file


I'm actually pretty much against UUoC. The cat example is much more resilient to modification. For instance, there are usually natural modifications considering filtering etc.

Anyway, since he said number we probably want `nl` not `wc`.

Separating pipe-setup from processing is sound engineering to me and makes things much easier. For instance as I iterate, I will have cat piped to head piped to filter but eventually I'll take the head out and run the whole thing. That's a trivial ^W versus moving around arguments and worrying about arg order, etc.


That's right regarding directly giving the filename for the program (here wc) to open itself.

However using the input redirect is fine, especially if you format it that way (which is exactly the same thing):

  <file wc -l
Then, adding another step is as natural as with cat:

  <file grep meh |wc -l


Useless use of `wc` :)

    <file grep -c meh


25 years using shells and I never thought to place input redirection at the front. Well, thank you!


I am confused. What's wrong with `wc -l < file | ... | ...`?

I know `< file wc -l | ... | ...` is identical because the redirection is done before the command is executed, but what does putting it in front help with?


Because I feel the other answers, though correct, are entirely missing out on clarity:

The first iteration looks like this:

<file head -n10 | grep foo | tr baz qux

The second iteration looks like this:

<file gzcat | head -n10 | grep foo | tr baz qux

It makes the change much easier, since the first thing written is the first thing that happens. In `gzcat < file`, the logical first step - reading and streaming file - is now the physical second step. Like a German sentence, whenever you want to prepend the file, you have to maintain an item in second position.


You can easily change that first command with muscle memory. That's why I use cat $file| but I guess <$file would work too.


As per James Taylor's comment above, using cat means you can easily replace it with head e.g. for testing.

And not change anything else in the pipeline.


I hate when people nitpick this stuff. What if we just straight prefer the first one?


There's a whole Wikipedia section for this:

https://en.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_cat


It all makes a lot more sense now. I'm glad I can add demoggification to my vocabulary.


I usually use cat, because I often build a pipeline by starting with

  head filename | ...
then just change "head" to "cat" when I get it working, or grep if I want to check parts of a file, etc.


Likewise here, it maintains the left-to-right direction and "one operation per | gap |"


Bad code is code smell.

In this particular case, people (like me) would wonder, "what's the point" and then go searching for the details of how `cat` and `wc` work, assuming that there's might be a reason the original developer wrote this code, as opposed to the simpler `wc -l` (i.e. Chesterton's Fence).


People usually use it because piped input is a known interface, you don't have to go digging through a man page or help page to figure out what flag is needed to accept input from a file. "Data flows from left-to-right" is also very intuitive, and you don't need to know the specifics of how your shell interprets a command line to figure out where to put the input redirection in the case of a more complicated shell command.


The point is I personally find it more ergonomic. Just like how I'll take a slightly longer route to avoid turning directly across traffic or avoid a particularly dangerous intersection.

Also, context is really important. Not that people on the internet ever stop to think about what the context is that the person is writing the code in. I don't write bash scripts that run mission critical workloads. I just ad-hoc type stuff into my shell to produce output I need for stuff at the time.


Well one reason is programs being smart (dumb) about output if they think that dev stdout is a dev console. Using an extra cat eliminates this.


or just:

  cat -n file


Or even:

    nl file


It uses `kitty` terminal's built in support for images. [0][1]

[0] https://sw.kovidgoyal.net/kitty/graphics-protocol.html [1] https://github.com/o2sh/onefetch/blob/master/src/image_backe...

Note: iTerm2 also has its own image display protocol and for something more generic there is Sixel or w3mimgdisplay (from w3m).


This is how I avoid this issue entirely:

    <link href=data:, rel=icon>
This is the smallest possible "null" favicon. It causes the browser to display nothing and ensures 0 HTTP requests for the favicon!


Does the browser display the generic "no favicon" icon, or is it just completely blank? I like the idea.


It's completely blank (tested in Firefox and Chromium).


This is something I started working on a couple of days ago, I hope you enjoy it!


Not exactly a 1:1 replacement though:

> This program requires access to /dev/uinput. This usually requires root permissions.

Source: https://github.com/ReimuNotMoe/ydotool#runtime

Edit: I'll also add that only 5~ commands have been implemented so far in ydotool.


We have quite a few patches in use too.

https://github.com/kisslinux/repo/search?l=Diff


Nothing stops a user from packaging and installing these things in KISS, they just aren't included by default.

I envision KISS as a minimal base in which you extend to suit your needs and not something you need to cut to size.

As I state in the Philosophy; "it's easier to add things to a system than it is to remove them".

A user has actually gone ahead and done this! \[1\] They run KISS with systemd, pam, dbus, pulseaudio, glibc, chrome etc etc.

\[1\] https://github.com/fanboimsft/kissD


But for me that beats the purpose. You still end up with the complexity. Only now you have to add and manage it yourself in some other way, probably being worse off then when you would have started with all that complexity but integrated in one standardised package (distro).

Imho, the issue is not that the solutions are complex but the problems we (assume we) need to solve are. Just making simple solutions that ignore the bigger problems underneath do not really help in the end.


The purpose can be to make a simple system, not an easy to use one. A simple system can maintain its simplicity by avoiding tackling complex problems - however if you want to tackle those problems yourself then, sure, you'll also need to handle that inherent complexity that the original system decided to avoid. But that is complexity you invite in, not something that the original system had.

That doesn't make the original system any simpler or more complex.


The Philosophy is "it's easier to do things that were already done before".

So the project is an arbitrary reduction of scope and then writing the implementation just for that scope.


Yeah, I spent a lot of time ensuring the website would load quickly and I do away with a lot of "optional" cruft.

There's no Javascript full stop, no stylesheets (all CSS is embedded in each page) and every page load is a single web request (with the exception of the screenshots page).

Even the SVG logo is embedded in the pages!

Writing it this way also causes each page to be self contained, a download of the HTML page includes all of the CSS, logo and information so it can easily be saved and viewed locally. :)


My main issue with the site is that in my browser i get the mobile version instead of the desktop since i do not use my browser maximized (i have a 1366x768 monitor). Isn't there any other way to figure out if i use a mobile phone instead of using the horizontal resolution?


I'll fix this, thanks for letting me know.


> The only remark I have regarding code quality is that the word splitting warning is disabled for the entirety of kiss: I would have disabled it on a per-occurence basis.

There are 8 occurrences of word splitting in the source, each and every one is intentional.

I also enable all lint errors when working on the package manager itself (to catch any unintentional word splitting which may slip through my fingers).

The ideal goal is to reduce the word splitting count to zero though! :)

(I'll go ahead and make the change you're suggesting until I do remove all word splitting).


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

Search: