10 ms·
Start all of your commands with a comma (2009)
- sctb 2y agoSimilarly, 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.
- Brajeshwar 2y agoThis 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/tag, I'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.
- abdusco 2y ago> I'd never (not so far) encounter a word or text that starts with a comma immediately followed by anything. Agreed. I prefer using `!bang`s for the same reason for expanding text.
- codetrotter 2y agoI use short custom command names like aa, st, di, dp, cm and le in some thin wrappers around git. One of these names actually collides with a utility that is installed by default on some systems. 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. 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. It’s just too comfortable to use these two-character tools of mine.
- oguz-ismail 2y agoThis. 1-3 character names should be reserved for user aliases/functions/scripts and standard utilities.
- deleted 2y ago[deleted]
- jmclnx 2y agoAll my personal commands begin with 'j'. Got real fun when java came around. Using commas is a rather interesting idea. But at least I did not start them with a 'k' (KDE) :)
- setopt 2y agoI tend to make all my git aliases into two-letter combos starting with g. So `gs` is `git status`, for example. Once in a while I actually really need GhostScript though, it’s brilliant for e.g. embedding fonts into PDF files. Usually I then go with `env gs`.
- MathMonkeyMan 2y agoI have `alias s='git status'` and I feel like I'm missing a finger when it's not there.
- MaulingMonkey 2y agoThis approach can lead to issues like `apt-get upgrade` launching dwarf fortress: https://askubuntu.com/questions/938606/dwarf-fortress-starting-during-apt-get-upgrade https://askubuntu.com/questions/938606/dwarf-fortress-starti...
- owl57 2y agoI hope that tools like apt-get run subcommands in a predictable environment and never leak interactive session's $PATH. Then nothing in $HOME will break them — that user just put his df executable in /usr/bin or somewhere like that.
- mozman 2y agoWhen 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. 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. Any tips from someone else on where they started to be hip again?
- L8D 2y agoI think the hip thing to do is just use your spare time to build stuff, and organically learn from building stuff. Self-sufficiency, creativity and generally being a self-starter is what's hip. More time spent building translates into an incentive to pickup tricks and relying on yourself to find hip solutions to actual problems.
- d0gsg0w00f 2y agoAlso in "management", also feel like my skills will atrophy if I don't keep up. What I do is make tools to make my life easier. For example, if there's a web service at work I use for mundane lookups I'll find out if it has an API and write a CLI for it to speed up my daily grind. Once it's tuned to my liking I'll share it with the team. I do struggle to convince others to try it. Not sure why. But I don't really care because I use the tools every day.
- james_marks 2y agoI built my side project in a separate, trendier stack than the one I’m comfortable with at work for this very reason. Just to see some new perspectives and be conversant in the trends. Some of the new stack now crosses over to work, and I have a deeper appreciation for some of the older pieces.
- bityard 2y agoGood idea overall, I must say. It's one more key press, but I'm pretty sure I would use underscore for the first character.
- kraktoos 2y agoNever thought about that, cool!
- genericacct 2y agobest idea i've read in a while, will do
- tedunangst 2y agoFunny. My ~/bin is filled with commands that I want to override the system version.
- mozman 2y agoWrappers or replacements? If it’s a wrapper do you remove local bin from path or hard code system path?
- tedunangst 2y agoYeah, shell script that runs /usr/bin/x or whatever.
- bqmjjx0kac 2y ago> 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. 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 ~/bin`.
- mozman 2y agoBut then you start using some tool that expects $0 in the system path and breaks causing frustration and debugging. Pick your poison
- bqmjjx0kac 2y agoFair point. I've been doing this for years and none of my scripts have ever caused any (noticeable) breakage, though. The danger is also mitigated because I only modify my own user's shell rc file. Any daemons running as root or their own user are unaffected.
- mekoka 2y agoArticle is from 2009. Plenty of prevalent short named tools have been released since then, causing exactly this sort of issues. Just thinking about it, "node" and "npm" come to mind.
- michaelcampbell 2y ago> causing exactly this sort of issues POTENTIALLY. This (for me, anyway), is a solution in search of a problem. Been using some sort of *nix since the early 90's, writing scripts and commands and aliases and functions the whole time - this has never once happened to me. It obviously _can_, and PROBABLY has, to some. But it's more a "can" than "will". Maybe I just name my homebrew stuff in a way that's unlikely to collide, dunno.
- spc476 2y ago
- sre2 2y agoI've been doing this for at least a decade. Was introduced to the idea by a colleague who might have read this blog post. 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't do it with git aliases, I have to live with them starting with a dot (via '[alias ""]' as a section).
- rahimnathwani 2y agoI'm curious how folks manage their important local configurations, e.g. - is your ~/bin directory a git repo? - if you git to manage your dot files, do you use hard links or soft links?
- mr_mitm 2y agoI use ansible
- nucleardog 2y agoThere are tools to manage it for you that I’m sure someone will come along and mention, but I’ve got a repo I check out at `~/.home`, then a shell script they just symlinks everything into place. So .bashrc is a symlink to ~/.home/.bashrc, ~/.config/nvim to ~/.home/.config/nvim, etc. It’s simple and only relies on having something sh-compatible available so portable now and in the future. To manage per-system tweaks, I have places that include an additional file based on hostname. For example my .bashrc has something like: if [ -f “$HOME/.bashrc.$HOSTNAME” ]; then source “$HOME/.bashrc.$HOSTNAME” if Which will include a bashrc file specific to that host if it exists. Been working well for me for… a decade now?
- asix66 2y agoRe your second question, here’s how I manage my dotfiles: https://github.com/andersix/dotfiles https://github.com/andersix/dotfiles
- codetrotter 2y agoI have some essential stuff for zsh config in a git repo. For my most important custom bins, they are written in Rust and published to crates.io so I cargo install them from there. It’s just one crate, with wrappers for the git commands that I use day to day In addition to this, I have host specific repos with some scripts. These scripts are not in my path but are instead scripts that run on a schedule from cron. These scripts run and log various facts about the machine such as zpool status and list installed packages, and auto-commit and push those to their repo. And the other kind of script I have invokes zfs send and recv to have automatic backups of data that I care about. In addition to this I have a couple other git repos for stuff that matters to me, which either runs via cron (retrieving data from 3rd parties on a schedule) or manually (processing some data). For neovim I stopped caring about having a custom RC file at all. I just use vanilla neovim now on my servers. On my laptop I use full blown IDEs from JetBrains for doing work.
- thanatos519 2y agoEncountering this idea 5 years allowed me to bring order to my bag of shell tricks! I have over 50 ,commands between aliases and ~/bin and my shell life is way smoother than the previous agglomeration.
- thrdbndndn 2y agoA kinda relevant question. I use Windows most of time. Like the author, I have bunch of CLI scripts (in Python mainly) which I put into my ~/bin/ equivalent. After setting python.exe as the default program for `.py` extension, and adding `.py` to `%pathext%`, I can now run my ~/bin/hello.py script at any path by just type `hello`, which I use hundreds of time a day. I now use Linux more and more (still a newbie) but I never get it to work similarly here. Firstly, Linux seems to have no concept of "associated program", so you can never "just" 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's hard-coded (what if in future I don't want to execute my .py script with `/usr/bin/python` but `/usr/bin/nohtyp`?). Furthermore, I failed to find any way to omit `.py` part when calling my script. Again, none of the above is to question the design of the Linux -- I know it comes with lots of advantages. But I really, really just want to run `hello` to call a `hello.py` script that is in my $PATH.
- rascul 2y ago> Firstly, Linux seems to have no concept of "associated program", so you can never "just" 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's hard-coded (what if in future I don't want to execute my .py script with `/usr/bin/python` but `/usr/bin/nohtyp`?). Might be you could use binfmt_misc for that. https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html https://www.kernel.org/doc/html/latest/admin-guide/binfmt-mi...
- MarkSweep 2y agoHere is an article about using binfmt_misc to make .go files executable. I assume something similar could be done for python: https://blog.cloudflare.com/using-go-as-a-scripting-language-in-linux/ https://blog.cloudflare.com/using-go-as-a-scripting-language...
- o11c 2y agobinfmt_misc is only useful for when a fileformat does not allow shebangs
- helpfulContrib 2y agoI dislike this immensely. It costs nothing to type "~/bin" in front of the command each and every time. And it means I can put comma's wherever I want in some commands that use them, like SQL .. I do, however, like to comment my custom commands: $ mv ~/Desktop/*pdf ~/Documents/PDF # pdfsync $ for i in ~/Documents/Development/JUCE/JUCE_Projects/* ; do ; cowsay $i ; cd $i ; git pull ; git fetch --all ; git submodule update --init --recursive ; done # updatejuce CTRL-R "updatejuce" or "pdfsync" .. and off we go .. A much nicer way of finding my custom commands ..
- adamomada 2y agoYou can do what you want but it’s not nothing: it costs six keystrokes every time (seven, counting shift for tilde)
- helpfulContrib 2y ago[dead]
- teo_zero 2y ago> 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 Please note that brackets have no special meaning to the shell.
- 38 2y agowrong https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
- adrian_b 2y agoBrackets have a special meaning in the UNIX shell since the earliest times. Together with "*" and "?", the brackets "[" and "]" have been used by the UNIX shell since some of its earliest versions (already many years before the Bourne shell) in pattern matching for pathname expansion (globbing). For example, if you have in a directory 3 files named "file1", "file2" and "file3", then "ls file?" will output file1 file2 file3 while "ls file[13]" will output file1 file3
- teo_zero 2y agoYes, of course I was too quick: I was trying to suggest to use a single bracket char in the command just as TFA uses the comma. But it turned out that an opening bracket wouldn't work with some non-bash shells. So I was doubly wrong.
- gdavisson 2y agoBrackets are used in shell wildcard ("glob") expressions. For example, if you try to use "[bar]" as a command, the shell will first look for files named "b", "a", and "r" in the current directory, and if it finds any it'll use the first one as the command name and any others as arguments to it. But as far as I can see, using a close-bracket as the first character in a command is safe, since it cannot be treated as part of such a pattern. Open-bracket (without a matching close-bracket) would work in many shells, but will get you a "bad pattern" error in zsh.
- 2y ago
- deleted 2y ago[deleted]
- jwilk 2y agoDiscussed in 2020: https://news.ycombinator.com/item?id=22778988 https://news.ycombinator.com/item?id=22778988 (90 comments)
- dang 2y agoThanks! , macroexpand: Start all of your commands with a comma (2009) - https://news.ycombinator.com/item?id=31846902 https://news.ycombinator.com/item?id=31846902 - June 2022 (121 comments) Start all of your commands with a comma (2009) - https://news.ycombinator.com/item?id=22778988 https://news.ycombinator.com/item?id=22778988 - April 2020 (89 comments)
- throwadobe 2y agoI see what you did there...
- declan_roberts 2y agoI like it I think. I'd probably be more inclined to add the comma to the end, that way tabbing on "mount" would bring up "mount and mount," which is your personal one.
- c22 2y agoI guess this works great right up to when the contents of ~/bin/ are added to a CSV for whatever reason.
- mixmastamyk 2y agoUse TSV instead.
- tgv 2y agoSo much better. And you don't have the ridiculous "localization" of csv: over here, the field separator defaults to a semicolon. I suppose someone thought it was so terribly important to have a decimal comma in a csv file that any form of common sense went out of the window.
- g15jv2dp 2y agoDoesn't work with powershell (which, to be fair, was quite new at the time this blog post was released). But honestly, while 2 or 3-letters aliases are tricky, I'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.
- genewitch 2y agowhat doesn't work about it? i made ",foo.bar" and i went into PS and typed ,<tab> and it said: > PS V:\> & '.\,foo.bar'
- g15jv2dp 2y agoThe goal is to have short aliases. That explicit call syntax isn't exactly convenient. That's what doesn't work.
- genewitch 2y agoi typed a literal comma, and then the tab button, and it put in the baker's dozen other characters. I only did this to see if "this doesn't work in powershell" was true, turns out it is not true. if i have ,foo.exe and ,cuda_install.exe in a directory (or on my path), it's two characters and then a tab, same as linux, to run either of them: ,c || ,f anyhow, it was for my own edification.
- TrianguloY 2y agoThose can really be called comma_nds! Ahem. Nice idea though, I think I'll start using it...
- RandomGuy45678 2y agoLove it!
- zuminator 2y agoSurely ,nds?
- zogrodea 2y agoI think "comma_nds" ("commands" if you remove the underscore) makes the pun mkre obvious. I didn't get it at first thought, thinking of the .nds file extension for Nintendo DS ROMs.
- Sophira 2y agoThe pun still holds as "comma,nds" though, and might even do so better.
- zogrodea 2y agoOh, I thought the user was suggesting using just ",nds" instead of "comma,nds". That makes more sense.
- Sophira 2y agoOh, they might have been. The joke might have gone completely over my head when I said that! Still though, it sounds like "comma,nds" would be a good compromise either way.
- ssivark 2y agoOr maybe ,&
- morningsam 2y agoAn 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't affect executables called from within scripts and you can still refer to your executables by their long names in your own scripts. One drawback is that this doesn't have the same tab completion ergonomics, which I have to admit is really nifty. 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's venv activation scripts). But those are rare.
- olejorgenb 2y ago> One drawback is that this doesn't have the same tab completion ergonomics, which I have to admit is really nifty. They do in zsh
- morningsam 2y agoI meant specifically that you can quickly see all your custom scripts (and only them) by tab-completing comma itself. Of course aliases have regular tab completion in bash as well.
- olejorgenb 2y agoAh, I thought you referred to completion of parameters etc. not working for aliases. I checked again now, and this does not work for bash. Of course - your own custom scripts usually wont have so fancy completion, and in any case you'd need to configure this and setting it up for both the long and short version is not that much hassle.
- klysm 2y agothings like this happen all the time when we didn’t implement name spacing when we should have
- lloydde 2y agoStarting with comma is also a common technique in the text expander / text replacement community.
- jbaber 2y agoYup. Most of my vim aliases begin with ,
- tanelpoder 2y agoGreat 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: $ cd ~/bin $ for x in $(find . -type f -perm /a=x -exec basename {} \;) ; do echo $x ; done temps $ for x in $(find . -type f -perm /a=x -exec basename {} \;) ; do ln -s $x ,$x ; done $ ls -l total 4 lrwxrwxrwx 1 tanel tanel 5 Jun 23 16:38 ,temps -> temps -rwxr--r-- 1 tanel tanel 251 May 30 23:26 temps
- metadat 2y agoDiscussed previously: https://news.ycombinator.com/item?id=22778988 https://news.ycombinator.com/item?id=22778988 (April 2020, 90 comments)
- dotancohen 2y agoI was recently poking around ~/.local/bin/ when I noticed that it had dozens of executables that I don'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. The idea about starting my own scripts' names with a comma would have made the job go much faster, and I'm sure would have helped to job some memories about why each script was written, before opening it.
- o11c 2y agoNormally ~/.local/bin/ is only for installed scripts; locally-written ones go in ~/bin/
- dotancohen 2y agoThanks. I used to use ~/.bin/ for locally-written scripts because I like that directory to be hidden, maybe I'll go back to doing that.
- I_o_IllI__o_I 2y ago[dead]
- deleted 2y ago[deleted]
- kazinator 2y agoNo thank you. Put your personal bin first in PATH, and use /usr/bin or /bin for referring to the shadowed programs. You can list your personalized tooling using ~/bin/[Tab] for whatever value there is in that.
- kazinator 2y agoI don't understand why you would shadow the system utilities with your own, yet not want to use identical names, so that you have to keep remembering to use the comma. If you don't like the system's grep (e.g. Solaris grep or whatever) but prefer your own (e.g. GNU grep), why wouldn't you just want that to be "grep".
- mikey_p 2y agoI think comma is probably one of the most commonly used keys for <leader> in Vim as well, probably for the same sort of reason.
- stevage 2y agoI don't really understand the problem it solves. can't you just put your own bin directory first in the PATH? I do like the idea of autocompleting your own commands though.
- ok_dad 2y agoI’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”.
- neilv 2y agoWith command completion, another option is to use descriptive names. 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 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't break any scripts, and I'll know if someday I'm typing one of those and intending to get something different. In a few cases, those one-letter aliases have been for very-often-used scripts of mine.
- CGamesPlay 2y agoI'm a fan of using argc for this <https://github.com/sigoden/argc https://github.com/sigoden/argc>. I have my `~/.local/bin/.argc` file, which has a bunch of commands that I wrote. The commands have inline documentation and documented parameters. Quite nice for rarely-used scripts!
- arjie 2y agoAh! I called them comma-commands https://wiki.roshangeorge.dev/index.php/Comma_command https://wiki.roshangeorge.dev/index.php/Comma_command and I was wondering what the source material was. Now I know! I feel like these small web people's blogs were so much more accessible before link aggregators got this mainstream.
- tripdout 2y agoThought this was going to be about Comma [0] 0: https://github.com/nix-community/comma https://github.com/nix-community/comma
- SuperNinKenDo 2y agoThe problem is that *nix has system utilities who'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. If we could go back to the drawing board I'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. This might seem like a moot point, since we can't go back to the drawing board, but many projects continue to make this problem worse by insisting on naming their binaries like we're still living with the constraints of the 80s. I guess because it gives them the flavour of "real" system utilities. It would be nice if projects stopped doing that, but oh well.
- victor141516 2y agoI use different namespaces for different convenience scripts, and use the notation [character].[command] for all of them. I've used a character for each company I've worked for, and a different one for common scripts. This way is very easy to clean $HOME when I move.
- codazoda 2y agoI like the idea of using periods for collections of commands. I have a todo list hacked together with shell scripts and I've been thinking about how I might want to stay away from collisions. I think I'll use do.thing style commands, so my commands will be: do.item Add an item to the bottom of my todo list do.soon List the items that I need to do soon do.next List the next item to work on do.mark Mark the current item done How do you implement namespaces? Is it just that you do this with all the commands you create for this company?
- victor141516 2y ago> How do you implement namespaces? Is it just that you do this with all the commands you create for this company? Exactly. It's super barebones but it works haha.
- codazoda 2y agoI liked the idea of this but it won't work for me in practice. A down-side of periods is that you can't use them in an `alias`. Since that is how I configure a lot of these commands the period is probably not an option I can use consistently.
- morgannewman 2y ago[dead]
- pablorosales 2y agoNice