Live data from Hacker News

Start all of your commands with a comma (2009)

rhodesmill.org

141–150 of 177 posts

Re: Start all of your commands with a comma (2009)

#141
With command completion, another option is to use descriptive names.

Just a few examples on this machine: backup-workstation-to-foo, backup-workstation-to-usb-restic, make-label-for-laptop-battery, set-x-keyboard-preferences, update-pocketbook

For one-letter and two-letter commands that might conceivably overlap with some command in some package someday (e.g., `gi` for `grep -i`), I only do those as interactive shell aliases. So they shouldn't break any scripts, and I'll know if someday I'm typing one of those and intending to get something different.

In a few cases, those one-letter aliases have been for very-often-used scripts of mine.

Re: Start all of your commands with a comma (2009)

#142
post #126

> Because my shell script names tended to be short and pithy collections of lowercase characters, just like the default system commands, there was no telling when Linux would add a new command that would happen to have the same name as one of mine. Not sure I understand this problem. I just put my bin directory at the front of $PATH rather than the end. To browse my commands, I simply `ls ~/bin`.

I just… remember the names I give things? Why is this considered a “hack” of some kind?

I go to my bin dir and list the files.

Re: Start all of your commands with a comma (2009)

#144

Earlier quoted context omitted.

Or maybe ,&

Commaands? I liike it

Commaet(s). & is Et, which means "and" in latin. Your read of it reminds me of the old Jack in the Box signage which, according to a good friend, looked like "Jack in the B-Fish"

Re: Start all of your commands with a comma (2009)

#145

I use short custom command names like aa, st, di, dp, cm and le in some thin wrappers around git. One of these names actually collides with a utility that is installed by default on some systems. Doesn’t matter to me. I have my own bin dirs before the system dirs in my path, so mine “win”, and I’m not really interested at all in the tool that mine has a name collision with. If someone were to make a useful to me tool…

Hot take: system commands shouldn't be as accessible as user commands. There should be some sort of namespacing. For example, mkfs should be invoked with `sys::mkfs` or something like that. The line that separates system and user commands may be defined in different ways, and it may be fuzzy in some places, but if a user accidentally invokes a command that they don't even know why is there, and they didn't explicitly…

i am unsure if RHEL/Cent did this, but at one of the places i worked you had to do /bin/ls. I expect this is much more common at places that do lots of acquisitions. that way if some random cron job relies on UB from some tool in order to not start the DC on fire, it doesn't matter. Admins use latest tooling, the software gets whatever it came with and was working until actual competent devs can look at it and move it to ansible or whatever puppet/chef i forget what they all used.

Re: Start all of your commands with a comma (2009)

#147

Doesn't work with powershell (which, to be fair, was quite new at the time this blog post was released). But honestly, while 2 or 3-letters aliases are tricky, I've very rarely had issues with 4-letter aliases. There are 456k possibilities. On my small opensuse install, my PATH contains only 105 4-letter executables.

what doesn't work about it? i made ",foo.bar"

and i went into PS and typed , and it said:

> PS V:\> & '.\,foo.bar'

Re: Start all of your commands with a comma (2009)

#149
post #141

With command completion, another option is to use descriptive names. Just a few examples on this machine: backup-workstation-to-foo, backup-workstation-to-usb-restic, make-label-for-laptop-battery, set-x-keyboard-preferences, update-pocketbook For one-letter and two-letter commands that might conceivably overlap with some command in some package someday (e.g., `gi` for `grep -i`), I only do those as interactive shell…

I'm a fan of using argc for this https://github.com/sigoden/argc>. I have my `~/.local/bin/.argc` file, which has a bunch of commands that I wrote. The commands have inline documentation and documented parameters. Quite nice for rarely-used scripts!

Re: Start all of your commands with a comma (2009)

#150
post #137
post #19

Earlier quoted context omitted.

But then you start using some tool that expects $0 in the system path and breaks causing frustration and debugging. Pick your poison

What is "system path"? Every tool inherits the caller's path. I don't think this could be a problem unless a tool talked directly to systemd to execute itself.

Default PATH minus ~/bin.
Post reply on HN