Live data from Hacker News

Start all of your commands with a comma (2009)

rhodesmill.org

51–60 of 130 posts

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

#52
I almost always add "," in cmd.exe to anything I run from Windows Command Prompt? Why? Because cygwin, or mingw's `dir.exe` would be called instead of built-in dir (well, this is further complicated that I don't really use `cmd.exe` but FAR Commander), so if I want to enforce the built-in over external (same name) command I have to prepend it with "," - so I basically started typing "," in front of each of my commands...

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

#53
I do something similar but 1. for aliases and 2. use period. For example, when working on a Rails project I define the following alias:

    function .routes() {
      if [[ $# -eq 0 ]]; then
        .rails routes
      else
        .rails routes | grep $@
      fi
    }
where .rails is another alias (for running bundle exec rails ...). I can then run ".routes webhook" and see all routes containing "webhook".

Last but not least, I automated the whole thing with bash-ctx (https://github.com/gregnavis/bash-ctx).

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

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

> I wish it was easier to create "snapshots" of a particular set of environment variables in order to use them later as run environments.

docker gives you this (but only as part of a whole ecosystem, which for various reasons you might not want to hitch your horse to).

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

#55
post #5

Quoted post unavailable.

Tomte has >100k karma (that seems insanely high, but also a 10+ year-old account), and a plethora of reposts in his submission history.

If you wanted to juice-up your karma (I can't fathom why someone would bother doing this), it seems like simply reposting popular submissions from previous years is a very easy way to do that (if it was popular on HN in years past, then it's likely it would again). I'm not saying that's Tomte's motivation.

This would also result in interesting/popular submissions resurfacing again and again, which anecdotally I can say I've seen quite a bit on HN. I don't think that's necessarily a bad thing, but perhaps it can get tedious for some. For example, I had not read this post before and found it useful/interesting.

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

#56
post #40

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…

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)

#58
post #34
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

> mkdir -p /tmp/bin/my This is not a secure way of using /tmp.

Sure, but that's not the point. It's just an illustrative example, and I wanted a short absolute path that is easily recognizable to the reader. I'll fix it, though, to avoid having an example with bad security practices, though.

edit: Or I would fix it, but I guess I can't edit it. Oh well.

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

#59
post #42

Earlier quoted context omitted.

Until you have five commands which all use the prefix `sort-incoming-` and then three commands named `sort-incoming-hourly` and `sort-incoming-monthly` etc.

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)

#60
post #39
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

Plan 9 does that, I'm not sure why it never made it into Unix because I always loved it. Your networking-related commands were in `/bin/ip` and you'd run e.g. `ip/ping 1.1.1.1`. If you created the dir `$home/bin/rc/my` and put scripts in it, they would have been runnable as `my/hello` etc like in your example.

Plan 9 also more or less does away with the concept of $PATH in the first place; just union-mount (with `bind`) whatever you want onto `/bin` and call it a day. Yet another thing that would've been great for Unix-likes to pull in (I think some Linuxen can technically do it, but with some limitations).
Post reply on HN