Start all of your commands with a comma (2009)
The article discusses creating a ~/bin/ directory in Unix to store custom commands, avoiding name collisions with system commands by prefixing custom commands with a comma. This technique ensures unique, easily accessible commands.
Read original articleThe author discusses the practice of creating a ~/bin/ directory in Unix systems to store custom commands and scripts. They highlight the issue of potential name collisions with system commands and share their solution of prefixing custom commands with a comma to differentiate them. This approach ensures unique command names that are easy to type and remember, while avoiding conflicts with system commands. The author emphasizes the convenience of tab-completion for accessing their custom commands quickly. They recommend this technique to users managing their own ~/bin/ directory to maintain organized and distinct command names. The strategy has proven effective for the author over a decade, offering a robust and enjoyable way to manage custom commands in Unix environments.
Related
Exposition of Front End Build Systems
Frontend build systems are crucial in web development, involving transpilation, bundling, and minification steps. Tools like Babel and Webpack optimize code for performance and developer experience. Various bundlers like Webpack, Rollup, Parcel, esbuild, and Turbopack are compared for features and performance.
Andrew S. Tanenbaum Receives ACM Software System Award
Andrew S. Tanenbaum, known for MINIX, receives ACM Software System Award for shaping OS education and influencing Linux's design. His microkernel work continues to impact OS development globally.
FreeBSD Bhyve Companion Tools
The author details transitioning from VirtualBox to FreeBSD Bhyve, praising Bhyve's benefits in a FreeBSD setting. Tools like VNC connection and pause/resume scripts optimize Bhyve operations, simplifying VM management.
Creating New Installation Media for MS-DOS 4.0
Microsoft released MS-DOS 4.00 source code in 2024, prompting the community to develop MS-DOS 4.01 due to missing official media. Challenges arose in recreating installation media, including creating stub executables and addressing missing files. Installation from floppies had mixed results, with various disk downloads provided for users. Feedback is welcomed on fabulous.community.
My weekend project turned into a 3 years journey
Anthony's note-taking app journey spans 3 years, evolving from a secure Markdown tool to a complex Electron/React project with code execution capabilities. Facing challenges in store publishing, he prioritizes user feedback and simplicity, opting for a custom online deployment solution.
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?
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`.
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.
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.
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.
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.
You can list your personalized tooling using ~/bin/[Tab] for whatever value there is in that.
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).
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.
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.
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.
$ 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
I do like the idea of autocompleting your own commands though.
- is your ~/bin directory a git repo?
- if you git to manage your dot files, do you use hard links or soft links?
I feel like these small web people's blogs were so much more accessible before link aggregators got this mainstream.
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.
Please note that brackets have no special meaning to the shell.
https://news.ycombinator.com/item?id=22778988 (April 2020, 90 comments)
Ahem. Nice idea though, I think I'll start using it...
It's one more key press, but I'm pretty sure I would use underscore for the first character.
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 ..
Related
Exposition of Front End Build Systems
Frontend build systems are crucial in web development, involving transpilation, bundling, and minification steps. Tools like Babel and Webpack optimize code for performance and developer experience. Various bundlers like Webpack, Rollup, Parcel, esbuild, and Turbopack are compared for features and performance.
Andrew S. Tanenbaum Receives ACM Software System Award
Andrew S. Tanenbaum, known for MINIX, receives ACM Software System Award for shaping OS education and influencing Linux's design. His microkernel work continues to impact OS development globally.
FreeBSD Bhyve Companion Tools
The author details transitioning from VirtualBox to FreeBSD Bhyve, praising Bhyve's benefits in a FreeBSD setting. Tools like VNC connection and pause/resume scripts optimize Bhyve operations, simplifying VM management.
Creating New Installation Media for MS-DOS 4.0
Microsoft released MS-DOS 4.00 source code in 2024, prompting the community to develop MS-DOS 4.01 due to missing official media. Challenges arose in recreating installation media, including creating stub executables and addressing missing files. Installation from floppies had mixed results, with various disk downloads provided for users. Feedback is welcomed on fabulous.community.
My weekend project turned into a 3 years journey
Anthony's note-taking app journey spans 3 years, evolving from a secure Markdown tool to a complex Electron/React project with code execution capabilities. Facing challenges in store publishing, he prioritizes user feedback and simplicity, opting for a custom online deployment solution.