top | item 47040257

(no title)

ktm5j | 13 days ago

I'm on my phone so I'm too lazy to dig for this, but I'm pretty sure they're talking about the bit of shell script that gets run if you type a command that isn't found in PATH.

Fedora and Debian will both dive straight into searching apt/dnf for a matching package and ask "do you want to install this?"

I imagine you could create a hook that gets run for any command failure, but again I'm on my phone so not sure.

discuss

order

VorpalWay|13 days ago

This is generally called a command-not-found handler and are a feature of all the major shells (though the exact details differ, the general idea is to define a function with a specific reserved name), and most majors distros have ones that can be installed, even if they aren't by default.

I wrote my own (much faster) such handler for Arch Linux. I even wrote a blog post about the design: https://vorpal.se/posts/2025/mar/25/filkoll-the-fastest-comm...

zahlman|13 days ago

I thought of that, but TFA describes a system that trips on incorrect filenames rather than just incorrect commands.

dataflow|13 days ago

ktm5j|13 days ago

which is run by bash in the way I described.

In /etc/bash.bashrc:

# if the command-not-found package is installed, use it if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then ... fi

aflag|13 days ago

I thought Ubuntu did that, but not Debian. Still, that's very different than what the author mentioned

ktm5j|13 days ago

Oh you might be right about Ubuntu vs Debian.. but I'm right about everything else I said. I went and looked at the source code.

bandrami|13 days ago

cachy's setup of fish tries to suggest commands (and even arguments) it might be, which I find terrifying and so turn off.