Start all of your commands with a comma (2009)
11–20 of 130 posts
Re: Start all of your commands with a comma (2009)
#12Because of some common layout of keyboards the \ and ] are near each other, or in reach of left and right pinkies I can type \]\ before the name of the tools. This means I don't even have add a dir to the path.
I am sure this violates someone sensibilities but it has saved time over the years as a consultant when I had to deal with a wonky machine and owner did not want permanent install of diagnostic tools.
Re: Start all of your commands with a comma (2009)
#13This 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)
Re: Start all of your commands with a comma (2009)
#14If 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.
Re: Start all of your commands with a comma (2009)
#15If 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.
Re: Start all of your commands with a comma (2009)
#16If 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.
Re: Start all of your commands with a comma (2009)
#17For example I have ‘_f’ aliased to a fuzzy find command that will launch vim on the selected files, and a different one for launching sql clients to various servers etc.
As a prefix, commas work great!
Re: Start all of your commands with a comma (2009)
#18I do basically the same thing with any aliases or commands that I have just for me. Except I prefix with _ (an underscore.) Having some sort of prefix is extremely nice as it ensures you never override a built-in on accident, AND it makes it easy to tab complete just the ones that you want. For example I have ‘_f’ aliased to a fuzzy find command that will launch vim on the selected files, and a different one for laun…
Re: Start all of your commands with a comma (2009)
#19Re: Start all of your commands with a comma (2009)
#20Clever trick. Too bad there's no good way to namespace commands. It would be interesting if you could have, for instance: $ mkdir -p /tmp/bin/my $ printf '%s\n%s\n' '#!/bin/sh' 'echo hello' > /tmp/bin/my/hello $ chmod 755 /tmp/bin/my/hello $ PATH="/tmp/bin:$PATH" $ my/hello hello
$ touch foo::bar
$ chmod +x foo::bar
$ ./foo::bar && echo $?
It's an empty file so it does nothing, but most shells' lexers should be smart enough to not try and lex '::'.Edit: Forgot to mention, this also works with bash functions and aliases. I'm not sure if POSIX sh will allow it. You can also do things like this (again, not sure I'd recommend it):
$ alias +x='chmod +x'