I use a similar trick for text expansion. All my abbreviations start with a semicolon (;). It’s on the home row, it never occurs at the start of a word in normal typing so I never have a false positive expansion, and it’s easy to remember.
Start all of your commands with a comma (2009)
121–130 of 130 posts
Re: Start all of your commands with a comma (2009)
#122Earlier quoted context omitted.
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)
#123Clever 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
What about: my hello I.e. only my needs to be in the global namespace and all other commands are resolved by my itself.
Re: Start all of your commands with a comma (2009)
#124Earlier quoted context omitted.
What about: my hello I.e. only my needs to be in the global namespace and all other commands are resolved by my itself.
You’d need to set up tab completion for the `my` command. This is more effort than just naming everything `my-foo` — or `,foo`.
Re: Start all of your commands with a comma (2009)
#125Earlier quoted context omitted.
Porque no los dos? It seems that function ,foo() { printf "Fooo\n"; } ,foo actually works! (at least in my bash 5.0.17 shell)
I know this is unimportant, but the phrase is "¿Por qué no los dos?".
Re: Start all of your commands with a comma (2009)
#126Earlier quoted context omitted.
It would be nice to have camel-case completion in the shell, i.e. have “SIH” be completed to “SortIncomingHourly” and “SIM” to “SortIncomingMonthly”, etc. (only for upper-case characters). That way one could get more mileage out of the possible character combinations.
Well, not exactly tab completion, but I have `fzf`[0] tied to my history search. That allows me to type `soriloco`, punch ctrl+r and be prompted with `some ridiculously long command` (if, of course, I've run it before). Combined with infinite history this trick has saved me a bunch of typing and even proper remembering. :P [0]: https://github.com/junegunn/fzf
Re: Start all of your commands with a comma (2009)
#127Re: Start all of your commands with a comma (2009)
#128Earlier quoted context omitted.
What has always been a blocker for me to follow your example, is the desire to use many such scripts from the command lines provided inside an $editor or $email client. There probably is a way to configure both of them to see the aliases, but it's more straightforward to just have everything in the PATH.
Yes, it seems cleaner to just put "export PATH=$HOME/bin:$PATH" in $HOME/.bashrc. That avoids collisions with /usr/bin and /usr/local/bin. (Or rather, resolves collisions in favor of your personal bin directory.)
Re: Start all of your commands with a comma (2009)
#129Earlier quoted context omitted.
I actually just learned from a different HN thread yesterday [1] that aliases do get expanded if you add this to your shell's rc file: alias watch='watch ' Specifically, if an alias ends with a space, it will cause the subsequent arg to be expanded as well. For example, try running: alias beep=echo watch beep hello # This will fail alias watch='watch ' watch beep hello # Now it works! [1]: https://news.ycombinator.co…
Brilliant feature, but this is the sort of thing that reinforces the idea that CLIs have awful discoverability compared to GUIs.
Re: Start all of your commands with a comma (2009)
#130Earlier quoted context omitted.
You could (ab)use home directories for that. I.e. place your hello into /home/my, and then you can invoke it as ~my/hello. You even get namespace completion for free after the `~`.
In zsh you can do "hash -d my=/path/to/my" and then you can use "~my/hello" from anywhere, and it doesn't need to be in /home.
Neither do home directories.