Live data from Hacker News

Start all of your commands with a comma (2009)

rhodesmill.org

121–130 of 130 posts

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

#121

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.

I am surprised to see someone else doing this, but I agree it works surprisingly well and one of my favorite tips.

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

#122
post #28
post #16

Earlier 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`.

Why use rsync? Only for the progress bar?

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

#123
post #8

Clever 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.

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)

#124
post #123

Earlier 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`.

Good point.

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

#125
post #62

Earlier 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?".

Thank you. In case others would wonder too: https://www.rae.es/espanol-al-dia/porque-porque-por-que-por-...

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

#126
post #42

Earlier 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

Yes, fuzzy matching is the way to go. Tab completion isn’t good enough any more.

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

#128
post #56
post #40

Earlier 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.)

Your PATH is inherited by child processes that you start, including scripts that expect the system version of commands that have the same name as your commands.

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

#129
post #112

Earlier 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.

Which is why CLIs should come with manuals - there is even a dedicated CLI program to view those (well multiple actually, because standards wouldn't be fun if there was only one).

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

#130
post #43

Earlier 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.

> and it doesn't need to be in /home.

Neither do home directories.

Post reply on HN