upvote
Looked so backwards to me, too. However, I decided to give it a go, anyway. Now, I have some scripts and small commands which start with a comma, and it looks neat and time saving.

Yes, I can do path ordering to override usual commands. However, having a set of odd-job scripts which start with a comma gives a nice namespacing capability alongside a well narrowed-down tab-completion experience.

While it's not the neatest thing around, it works surprisingly well.

Another idea which looks useless until you start using is text expanders (i.e.: Espanso and TextExpander).

reply
Either adding your script directory in front of the PATH, or creating `alias` that provide a full path to your script where a conflict exists, makes a whole lot more sense to me.

I've never had this collision problem yet, despite appending my script directory to the end, but I'll use either of the above solutions if that ever becomes a problem.

reply
Just on your first suggestion, this also means that if a person or process can drop a file (unknown to you) into your ~/bin/ then they can wreak havoc. Eg they can override `sudo` to capture your password, or override `rm` to send your files somewhere interesting, and so on.

Btw on the second suggestion, I think there's a command named `command` that can help with that sort of thing, avoids recursive pitfalls.

reply
That would require someone to already want to sabotage me in particular, learn my private workflows, and also have write access to my home folder. At that point, All is Lost.

Don't tell people to sacrifice agency for apocalypse insurance that doesn't work, lol

reply
If someone can drop a file in your ~/bin, they can also edit your shell’s startup files to add their malicious command.
reply
I think it's already game over if they have access to your home directory. They can also edit your path at that point.
reply
The issue of rootless malicious command overrides is solved by typing the whole path, such as "/bin/sudo".
reply
While true, what you describe is very unlikely to happen and most definitely won’t happens on systems where i’m the only users.
reply
I do this, and routinely shadow commands with my own wrappers to do things like set environment variables.

And then there’s Claude. It deletes whatever it finds at ~/.local/bin/claude, so I have to use a shell function instead to invoke the full path to my wrapper.

reply
You can use an alias, which takes priority over $PATH. e.g. I have this in .zhsrc to override the "claude" executable to run it in the OS sandbox:

    alias claude="sandbox-exec -f ~/agents-jail.sb ~/.local/bin/claude --dangerously-skip-permissions"
reply
How does your sandbox ruleset look? I've been using containers on Linux but I don't have a solution for macOS.
reply
I do the same thing, but I also have a command that shows me what functions or scripts might be shadowing other scripts
reply
Care to share?
reply
Any severe side effects so far? Have you set PATH up somehow so it is effect only on interactive prompt, and not in the launched processes?

Because I cannot imagine much 3rd party scripts working with random flags added to core tools

reply
I also do this.

Random flags added to core tools are done with aliases, which do not affect the launched processes, not by shadowing them in ~/bin. Shadowing in ~/bin are for cases where a newer (compared to the system-wide version) or custom version of a tool is needed.

reply
deleted
reply
> If I introduce an executable with a name, that overrides a system one

... and breaks existing scripts that reference the system one, right?

reply
Not if it is an alias.
reply
But yes if it’s another executable.
reply
curious if you're customizing anyway, why not use eg ripgrep?
reply
repgrep's CLI options and general behavior are different from grep. I tend to use both for different things.
reply
deleted
reply
Not OP, but I use ripgrep and customize it with an alias as well, so it applies equally there
reply