Live data from Hacker News

Start all of your commands with a comma (2009)

rhodesmill.org

61–70 of 130 posts

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

#61
The comma is employed in bash and other shell for brace expansion.[1] I can't see how this would conflict with OP's master plan, but I have fundamental objections towards the depths of OP's laziness. Lazy is ok, but there should not be competition to see who can be laziest. At some point, things just won't compress any further, and the attempt at further streamlining efficiency beyond what is useful has a negative effect on efficiency overall. Besides, tab completion is fine as it is and doesn't need what passes for a hack these days. To be clear, contrary to what OP has claimed about not being creative enough to come up with original script names that won't conflict with the flood of new Linux commands every update (wot? LOL), this is only about the OP not being satisfied with tab completion.

[1] https://superuser.com/a/184493

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

#62

I do something a bit special... Instead of naming my script foobarnator (and hence risking that another foobarnator may exist in the future and may clash with my script), I name my script foobarnatorToBeAliased.sh . Then in my list of aliases I alias foobarnator to foobarnatorToBeAliased.sh . The alias itself looks a bit weird in that to pass arguments to an aliased command you need to use a function (in Bash at leas…

Porque no los dos? It seems that

    function ,foo() { printf "Fooo\n"; }
    ,foo
actually works! (at least in my bash 5.0.17 shell)

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

#63
post #47

This brought https://github.com/Shopify/comma to mind

Do you know any of the history of why your link to `.../Shopify/...` redirects to `.../nix-community/...`? Is the latter an open-source contribution by Shopify?

I think it was originally developed and maintained by Shopify, but was then handed off to the nix community

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

#64
post #15

Earlier quoted context omitted.

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

Direnv has been mentioned, and it meshes well with functional package managers like Nix and Guix, each of which include the concept of "Profiles". Each profile can access a specific set of programs via it's environment, but PATH is far from the last variable that you can use Direnv or Profiles to control.

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

#66

I do something a bit special... Instead of naming my script foobarnator (and hence risking that another foobarnator may exist in the future and may clash with my script), I name my script foobarnatorToBeAliased.sh . Then in my list of aliases I alias foobarnator to foobarnatorToBeAliased.sh . The alias itself looks a bit weird in that to pass arguments to an aliased command you need to use a function (in Bash at leas…

> The alias itself looks a bit weird in that to pass arguments to an aliased command you need to use a function (in Bash at least AFACIT) but it all works fine.

No you don't:

    $ alias say=echo
    $ say beep
    beep
You do need to do something special the other way around (if you wrap a command in a function it needs to explicitly pass the arguments on).

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

#67
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

zsh can do this if you set the PATH_DIRS option, but if I remember right it doesn't autocomplete deeply nested directories, just one level.

I made a little tool that dispatches hierarchical commands in a slightly nicer way, with intelligent autocomplete with command descriptions: https://github.com/ianthehenry/sd

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

#68

I do something a bit special... Instead of naming my script foobarnator (and hence risking that another foobarnator may exist in the future and may clash with my script), I name my script foobarnatorToBeAliased.sh . Then in my list of aliases I alias foobarnator to foobarnatorToBeAliased.sh . The alias itself looks a bit weird in that to pass arguments to an aliased command you need to use a function (in Bash at leas…

I used to do this, but it doesn't work with things like "watch".

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

#69
post #43
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

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.
Post reply on HN