Friday, October 22, 2021

Begin All Of Your Commands With A Comma

Like many Unix users, I long ago created a ~/bin/ directory in my residence directory and added it to my PATH so that I could supplement the wonderfully wealthy set of primary Unix commands with some conveniences and shell scripts of my very own devising.


The issue, in fact, was the prospect of collision. As a result of my shell script names tended to be short and pithy collections of lowercase characters, simply like the default system commands, there was no telling when Linux would add a new command that might occur to have the identical identify as one in every of mine. This was truly not very probably on, say, a System V Revision three workstation in the 1980s, but the trouble grew to become quite a bit extra acute after i moved into the world of Debian. Purple Hat never really anxious me, because they packaged (comparatively) so little software program. But Debian right now supports a huge variety of commands; my modest Ubuntu laptop shows several thousand available:


The solution was obviously to adjust my command names in such a approach that they had been still simple to kind, but would by no means be chosen as system command names. For me, “easy to type” means not having to use the shift key, and only a few characters turned out to be obtainable, unshifted, on a trendy keyboard. The decrease-case letters are the very characters used in system commands; brackets, backslashes, the colon, the again-tick, and the one-tick all had a particular that means to the shell; and the slash and dot characters both imply something particular in a filename. (The slash divides listing names from filenames, and thus cannot seem in a filename itself, whereas the dot means “hide this file from regular browsing” if it leads the name, and separates a file from its extension in lots of different circumstances.)


There was but one character left: the easy, modest comma.


A fast experiment revealed in a flash that the comma was exactly the character that I had been searching for! Every instrument and shell that lay in arm's attain handled the comma as a perfectly regular and unobjectionable character in a filename. By merely prefixing each of my custom commands with a comma, they turned completely distinct from system commands and thus free from any probability of a collision.


And, best of all, due to the magic of tab-completion, it turned very simple to browse my complete assortment of commands. When trying to recollect which of my commands are available in my ~/bin/ listing on a given system, or when merely attempting to remember what some of my commands are known as, I merely kind a comma followed by tab and my listing of commands appears:


I heartily recommend this method to anybody with their own ~/bin/ listing who wants their command names kept clean, tidy, and fully orthogonal to any commands that the future would possibly carry to your system. The strategy has labored for me for something like a decade, so you should find it immensely sturdy. And, finally, it is just plain enjoyable.


No comments:

Post a Comment

What NCAA Tournament Champs Might Look Like In 2021-22

The primary men’s basketball nationwide title is in the trophy case for Baylor. Now what can the Bears do for an encore? Asking for a repeat...