TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Start all of your commands with a comma (2009)

411 pointsby vmbrasseur11 months ago

36 comments

mozman11 months ago
When I read the headline I thought this was going to be a terrible idea but I quite like it, especially the bit about using tab to list all your tooling.<p>Anecdotally I haven’t had many namespaces collisions recently. I’ve also let myself go a bit after going into management. My tech skills are 10 years too old.<p>Any tips from someone else on where they started to be hip again?
评论 #40770886 未加载
评论 #40771200 未加载
评论 #40771300 未加载
bqmjjx0kac11 months ago
&gt; Because my shell script names tended to be short and pithy collections of lowercase characters, just like the default system commands, there was no telling when Linux would add a new command that would happen to have the same name as one of mine.<p>Not sure I understand this problem. I just put my bin directory at the front of $PATH rather than the end. To browse my commands, I simply `ls ~&#x2F;bin`.
评论 #40769583 未加载
评论 #40771875 未加载
评论 #40769600 未加载
评论 #40770399 未加载
codetrotter11 months ago
I use short custom command names like aa, st, di, dp, cm and le in some thin wrappers around git.<p>One of these names actually collides with a utility that is installed by default on some systems.<p>Doesn’t matter to me. I have my own bin dirs before the system dirs in my path, so mine “win”, and I’m not really interested at all in the tool that mine has a name collision with.<p>If someone were to make a useful to me tool that collided with one of my own tools, I’d probably sooner alias that other tool to a new name that didn’t collide with mine, than to change any of my own tool names.<p>It’s just too comfortable to use these two-character tools of mine.
评论 #40771602 未加载
评论 #40769490 未加载
评论 #40770437 未加载
评论 #40769498 未加载
评论 #40771806 未加载
thrdbndndn11 months ago
A kinda relevant question.<p>I use Windows most of time. Like the author, I have bunch of CLI scripts (in Python mainly) which I put into my ~&#x2F;bin&#x2F; equivalent.<p>After setting python.exe as the default program for `.py` extension, and adding `.py` to `%pathext%`, I can now run my ~&#x2F;bin&#x2F;hello.py script at any path by just type `hello`, which I use hundreds of time a day.<p>I now use Linux more and more (still a newbie) but I never get it to work similarly here.<p>Firstly, Linux seems to have no concept of &quot;associated program&quot;, so you can never &quot;just&quot; call .py file, and let the shell to know to use python to execute it. Sure, you can chmod +x to the script, but then you have to add a shebang line directly to the script itself, which I always feel uncomfortable since it&#x27;s hard-coded (what if in future I don&#x27;t want to execute my .py script with `&#x2F;usr&#x2F;bin&#x2F;python` but `&#x2F;usr&#x2F;bin&#x2F;nohtyp`?).<p>Furthermore, I failed to find <i>any</i> way to omit `.py` part when calling my script.<p>Again, none of the above is to question the design of the Linux -- I know it comes with lots of advantages.<p>But I really, really just want to run `hello` to call a `hello.py` script that is in my $PATH.
评论 #40769655 未加载
评论 #40769740 未加载
评论 #40769615 未加载
评论 #40769814 未加载
评论 #40769739 未加载
评论 #40769621 未加载
评论 #40769616 未加载
评论 #40769718 未加载
评论 #40769656 未加载
评论 #40769844 未加载
评论 #40769626 未加载
评论 #40769641 未加载
评论 #40769803 未加载
评论 #40769614 未加载
评论 #40769825 未加载
评论 #40769669 未加载
评论 #40769812 未加载
评论 #40769648 未加载
评论 #40771934 未加载
评论 #40769659 未加载
评论 #40769745 未加载
评论 #40769620 未加载
morningsam11 months ago
An alternative method for avoiding collisions in PATH is to use really long executable names that are unlikely to be used by other executables and then have shorter aliases for them in your bashrc. The aliases won&#x27;t affect executables called from within scripts and you can still refer to your executables by their long names in your own scripts.<p>One drawback is that this doesn&#x27;t have the same tab completion ergonomics, which I have to admit is really nifty.<p>EDIT: And another is that collisions can still occur in scripts that need to be sourced rather than executed as a sub-process (like Python&#x27;s venv activation scripts). But those are rare.
评论 #40770906 未加载
lloydde11 months ago
Starting with comma is also a common technique in the text expander &#x2F; text replacement community.
评论 #40772243 未加载
dotancohen11 months ago
I was recently poking around ~&#x2F;.local&#x2F;bin&#x2F; when I noticed that it had dozens of executables that I don&#x27;t remember putting there. Mostly pyside things, but some other scripts as well. I really had to open each to jog my memory, especially about which scripts I had written myself and which were by other people.<p>The idea about starting my own scripts&#x27; names with a comma would have made the job go much faster, and I&#x27;m sure would have helped to job some memories about why each script was written, before opening it.
评论 #40770678 未加载
kazinator11 months ago
No thank you. Put your personal bin first in PATH, and use &#x2F;usr&#x2F;bin or &#x2F;bin for referring to the shadowed programs.<p>You can list your personalized tooling using ~&#x2F;bin&#x2F;[Tab] for whatever value there is in that.
评论 #40772277 未加载
thanatos51911 months ago
Encountering this idea 5 years allowed me to bring order to my bag of shell tricks! I have over 50 ,commands between aliases and ~&#x2F;bin and my shell life is way smoother than the previous agglomeration.
jwilk11 months ago
Discussed in 2020:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988</a> (90 comments)
评论 #40769917 未加载
sre211 months ago
I&#x27;ve been doing this for at least a decade. Was introduced to the idea by a colleague who might have read this blog post.<p>I usually do the same with commands where you are able to create sub-commands too, like git-,home (which allows you to run `git ,home add -p` and it conveniently set GIT_DIR to something and GIT_WORKTREE to $HOME). Sadly you can&#x27;t do it with git aliases, I have to live with them starting with a dot (via &#x27;[alias &quot;&quot;]&#x27; as a section).
Brajeshwar11 months ago
This works for text-expansion snippets too. All of the text expansions that I do with Alfred (other tools might work, too) are all comma phrases. I realize that writing English or even programming scripts&#x2F;tag, I&#x27;d never (not so far) encounter a word or text that starts with a comma immediately followed by anything. I used to use period but have stumbled on instances such as file extension where a period can be followed by words.
评论 #40769502 未加载
SuperNinKenDo11 months ago
The problem is that *nix has system utilities who&#x27;s binaries are named in such a way to make it difficult to replace the nice shorthands that are useful during interactive use, because they may cause problems during script execution.<p>If we could go back to the drawing board I&#x27;d say every system utlity should have a verbose name with some kind of aliasing system that provides easy shorthands to them. Then the shorthands could be replaced easily, with the verbose names being used during scripting.<p>This might seem like a moot point, since we can&#x27;t go back to the drawing board, but many projects continue to make this problem worse by insisting on naming their binaries like we&#x27;re still living with the constraints of the 80s. I guess because it gives them the flavour of &quot;real&quot; system utilities. It would be nice if projects stopped doing that, but oh well.
g15jv2dp11 months ago
Doesn&#x27;t work with powershell (which, to be fair, was quite new at the time this blog post was released).<p>But honestly, while 2 or 3-letters aliases are tricky, I&#x27;ve very rarely had issues with 4-letter aliases. There are 456k possibilities. On my small opensuse install, my PATH contains only 105 4-letter executables.
评论 #40772663 未加载
neilv11 months ago
With command completion, another option is to use descriptive names.<p>Just a few examples on this machine: backup-workstation-to-foo, backup-workstation-to-usb-restic, make-label-for-laptop-battery, set-x-keyboard-preferences, update-pocketbook<p>For one-letter and two-letter commands that might conceivably overlap with some command in some package someday (e.g., `gi` for `grep -i`), I only do those as interactive shell aliases. So they shouldn&#x27;t break any scripts, and I&#x27;ll know if someday I&#x27;m typing one of those and intending to get something different.<p>In a few cases, those one-letter aliases have been for very-often-used scripts of mine.
评论 #40772717 未加载
tanelpoder11 months ago
Great idea! And if for some reason you feel like your filenames should stay as they are (without a comma), you could just add symlinks to all executable files in your bin directory:<p><pre><code> $ cd ~&#x2F;bin $ for x in $(find . -type f -perm &#x2F;a=x -exec basename {} \;) ; do echo $x ; done temps $ for x in $(find . -type f -perm &#x2F;a=x -exec basename {} \;) ; do ln -s $x ,$x ; done $ ls -l total 4 lrwxrwxrwx 1 tanel tanel 5 Jun 23 16:38 ,temps -&gt; temps -rwxr--r-- 1 tanel tanel 251 May 30 23:26 temps</code></pre>
sctb11 months ago
Similarly, some Lisps (like Scheme48 IIRC) use a comma to begin REPL commands (as distinct from Lisp forms) because commas outside of quasiquotation forms are otherwise syntax errors.
stevage11 months ago
I don&#x27;t really understand the problem it solves. can&#x27;t you just put your own bin directory first in the PATH?<p>I do like the idea of autocompleting your own commands though.
rahimnathwani11 months ago
I&#x27;m curious how folks manage their important local configurations, e.g.<p>- is your ~&#x2F;bin directory a git repo?<p>- if you git to manage your dot files, do you use hard links or soft links?
评论 #40769755 未加载
评论 #40769713 未加载
评论 #40769639 未加载
评论 #40770066 未加载
评论 #40770038 未加载
评论 #40769683 未加载
评论 #40769729 未加载
评论 #40769790 未加载
评论 #40769738 未加载
评论 #40769827 未加载
评论 #40769692 未加载
评论 #40769951 未加载
评论 #40769679 未加载
评论 #40769878 未加载
评论 #40769744 未加载
评论 #40769633 未加载
arjie11 months ago
Ah! I called them comma-commands <a href="https:&#x2F;&#x2F;wiki.roshangeorge.dev&#x2F;index.php&#x2F;Comma_command" rel="nofollow">https:&#x2F;&#x2F;wiki.roshangeorge.dev&#x2F;index.php&#x2F;Comma_command</a> and I was wondering what the source material was. Now I know!<p>I feel like these small web people&#x27;s blogs were so much more accessible before link aggregators got this mainstream.
ok_dad11 months ago
I’ve used this method for a while now, not sure if it’s from this particular article or if someone else blogged the same idea. I also prefix any aliases or sh functions from my rc file with a comma. Mostly it gets me easy to find custom commands when I “forget what I called that one alias”.
victor14151611 months ago
I use different namespaces for different convenience scripts, and use the notation [character].[command] for all of them.<p>I&#x27;ve used a character for each company I&#x27;ve worked for, and a different one for common scripts. This way is very easy to clean $HOME when I move.
评论 #40775288 未加载
tedunangst11 months ago
Funny. My ~&#x2F;bin is filled with commands that I want to override the system version.
评论 #40769570 未加载
teo_zero11 months ago
&gt; The lower-case letters are the very characters used in system commands; brackets, backslashes, the colon, the back-tick, and the single-tick all had a special meaning to the shell<p>Please note that brackets have no special meaning to the shell.
评论 #40769905 未加载
评论 #40769886 未加载
评论 #40769788 未加载
评论 #40772096 未加载
declan_roberts11 months ago
I like it I think. I&#x27;d probably be more inclined to add the comma to the end, that way tabbing on &quot;mount&quot; would bring up &quot;mount and mount,&quot; which is your personal one.
tripdout11 months ago
Thought this was going to be about Comma [0]<p>0: <a href="https:&#x2F;&#x2F;github.com&#x2F;nix-community&#x2F;comma">https:&#x2F;&#x2F;github.com&#x2F;nix-community&#x2F;comma</a>
metadat11 months ago
Discussed previously:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988</a> (April 2020, 90 comments)
TrianguloY11 months ago
Those can really be called comma_nds!<p>Ahem. Nice idea though, I think I&#x27;ll start using it...
评论 #40770808 未加载
评论 #40770220 未加载
mikey_p11 months ago
I think comma is probably one of the most commonly used keys for &lt;leader&gt; in Vim as well, probably for the same sort of reason.
c2211 months ago
I guess this works great right up to when the contents of <i>~&#x2F;bin&#x2F;</i> are added to a CSV for whatever reason.
评论 #40770225 未加载
bityard11 months ago
Good idea overall, I must say.<p>It&#x27;s one more key press, but I&#x27;m pretty sure I would use underscore for the first character.
genericacct11 months ago
best idea i&#x27;ve read in a while, will do
kraktoos11 months ago
Never thought about that, cool!
pablorosales11 months ago
Nice
klysm11 months ago
things like this happen all the time when we didn’t implement name spacing when we should have
helpfulContrib11 months ago
I dislike this immensely. It costs nothing to type &quot;~&#x2F;bin&quot; in front of the command each and every time. And it means I can put comma&#x27;s wherever I want in some commands that use them, like SQL ..<p>I do, however, like to comment my custom commands:<p><pre><code> $ mv ~&#x2F;Desktop&#x2F;*pdf ~&#x2F;Documents&#x2F;PDF # pdfsync $ for i in ~&#x2F;Documents&#x2F;Development&#x2F;JUCE&#x2F;JUCE_Projects&#x2F;* ; do ; cowsay $i ; cd $i ; git pull ; git fetch --all ; git submodule update --init --recursive ; done # updatejuce </code></pre> CTRL-R &quot;updatejuce&quot; or &quot;pdfsync&quot; .. and off we go ..<p>A much nicer way of finding my custom commands ..
评论 #40772127 未加载