Live data from Hacker News

Start all of your commands with a comma (2009)

rhodesmill.org

21–30 of 130 posts

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

#22
post #15
post #11

If I unknowingly named my command the same as some system command and the custom command ends up earlier in my path it doesn't really cause any problems does it? I wasn't using that system command anyways, and my custom command is only going to take priority if my .bashrc file was run first.

It can if you are executing programs that then try to execute those commands and get your commands instead.

I wish it was easier to create "snapshots" of a particular set of environment variables in order to use them later as run environments. I also wish that Unix desktop environments generally made it easier to manage env vars, but that's another complaint. And don't get me started on PAM env vars...

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

#25
I tend to give programs longer, more descriptive names and then do the short names as shell aliases. That way there’s little risk of name collision for the original program, scripts using the canonical name remain readable, and the shorthand is free to evolve to fit varying work habits.

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

#26
post #13
post #2

This is a good trick to avoid collisions with system commands. Anytime you add one of your own executables to PATH, prefix it with a comma (,). This way you avoid name collisions and have a handy way of seeing what commands are available on your system using tab completion (, then tab lists all of your personal executables)

Is this comment from a bot? You just reiterated everything from the article.

This is an explanation that the parent comment simply reiterated the point of the article rather than adding content.

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

#27
post #5

Quoted post unavailable.

Reposts are ok after a year or so. This is in the FAQ: https://news.ycombinator.com/newsfaq.html.

Could you please review the site guidelines at https://news.ycombinator.com/newsguidelines.html and stick to them? Your last sentence there breaks more than one of the rules.

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

#28
post #16
post #11

If I unknowingly named my command the same as some system command and the custom command ends up earlier in my path it doesn't really cause any problems does it? I wasn't using that system command anyways, and my custom command is only going to take priority if my .bashrc file was run first.

Yes, all of that. And if you later decide to start using the system command, you just rename your custom command.

I use zsh and have the following alias (rather, function):

``` cp () { rsync -avhW --progress --inplace ${@} } ```

If I ever need to use the `cp` binary, I execute `=cp`, which evaluates to `/bin/cp`.

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

#29
post #25

I tend to give programs longer, more descriptive names and then do the short names as shell aliases. That way there’s little risk of name collision for the original program, scripts using the canonical name remain readable, and the shorthand is free to evolve to fit varying work habits.

My keyboard came with a tab key, so I don't worry about my commands having short names.
Post reply on HN