48 comments

  • mathfailure11 hours ago
    I didn&#x27;t like the idea. I prefer the alternative approach: _I_ decide the order of dirs in the PATH env. If I introduce an executable with a name, that overrides a system one - I probably do that intentionally.<p>If I introduce an alias (like `grep=&#x27;grep --binary-files=without-match --ignore-case --color=auto`) that matches the name of a system binary - I probably do that intentionally.<p>And if I EVER need to call grep without my alias - I just prefix it with a backslash: \grep will search with case sensitivity and no color and will scan binaries.
    • godelski12 minutes ago
      <p><pre><code> &gt; I just prefix it with a backslash: \grep </code></pre> I have an almost identical grep alias.<p>Word of warning, I use `\grep` quite frequently. The usage is when you are piping after grep or saving to a variable.<p>Illustrative example:<p><pre><code> $ TO_DL=$(curl &quot;https:&#x2F;&#x2F;foo.com&#x2F;releases&#x2F;&quot; \ | grep -e &quot;latest&quot; \ | head -n1 \ ) $ curl $TO_DL curl: (3) bad range in URL position XX https:&#x2F;&#x2F;foo.com&#x2F;releases&#x2F;latest.tar.gz ^^^^^^ </code></pre> Annoyingly `--color=auto` can change the representation of the characters so when you run again there&#x27;s a mismatch. I just find `\grep` easier than `grep --color=never`.<p>Annoying footgun, but something to be aware of in case you go down this extremely confusing rabbit hole like me. I couldn&#x27;t figure it out until I decided to hexdump the string.<p>[Side note]: My first thought reading the article was also about how `\` basically solves the problem but they do have one advantage in that they can do `,&lt;tab&gt;` and get a list of all their custom commands. Personally not worth it for me but I can definitely see this being useful for some. Especially on shared systems. But getting everyone to prefix a script name seems just as unlikely as getting everyone to place programs in the right location.
    • bayindirh8 hours ago
      Looked so backwards to me, too. However, I decided to give it a go, anyway. Now, I have some scripts and small commands which start with a comma, and it looks neat and time saving.<p>Yes, I can do path ordering to override usual commands. However, having a set of odd-job scripts which start with a comma gives a nice namespacing capability alongside a well narrowed-down tab-completion experience.<p>While it&#x27;s not the neatest thing around, it works <i>surprisingly</i> well.<p>Another idea which looks useless until you start using is text expanders (i.e.: Espanso and TextExpander).
      • mathfailure7 hours ago
        I never knew that what I&#x27;ve known as &#x27;hotstrings&#x27; (since the AutoHotKey days) other sometimes also call &#x27;text expanders&#x27;.
      • xbryanx8 hours ago
        Love Alfred Snippets for this same text expander need.
      • aschla4 hours ago
        The irony in the number of extra commas you&#x27;ve used in this comment...
        • bayindirh3 hours ago
          As a non-native English speaker and writer&#x2F;typer I&#x27;m not well versed in usage of commas unfortunately.<p>Feel free to add the required ones while reading this comment.<p>Sorry for the inconvenience this might create.
          • mh-2 hours ago
            As a native speaker the original comment seemed completely fine, ignore them. Also, I never would never guessed that you weren&#x27;t also a native English speaker.
            • tempestn45 minutes ago
              Agreed. The commas before the sentence-ending &#x27;too&#x27; and &#x27;anyway&#x27; were perhaps slightly unusual, but not enough so that I even noticed them, and I don&#x27;t think either is incorrect. All the rest were perfectly normal.
    • mid-kid11 hours ago
      Either adding your script directory in front of the PATH, or creating `alias` that provide a full path to your script where a conflict exists, makes a whole lot more sense to me.<p>I&#x27;ve never had this collision problem yet, despite appending my script directory to the end, but I&#x27;ll use either of the above solutions if that ever becomes a problem.
      • alsetmusic6 hours ago
        From my own aliases:<p><pre><code> alias curl=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;opt&#x2F;curl&#x2F;bin&#x2F;curl &#x27; alias rsync-copy=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;rsync -avz --progress -h &#x27; alias rsync-move=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;rsync -avz --progress -h --remove-source-files &#x27; alias rsync-synchronize=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;rsync -avzu --delete --progress -h &#x27; alias rsync-update=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;rsync -avzu --progress -h &#x27; alias vi=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;vim -S ~&#x2F;.vimrc&#x27; alias vim=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;vim -S ~&#x2F;.vimrc&#x27; alias wget=&#x27;&#x2F;opt&#x2F;homebrew&#x2F;bin&#x2F;wget -c &#x27; </code></pre> There are others with flags added. These are the ones that override the builtin MacOS versions that aren&#x27;t up-to-date.
      • mathfailure7 hours ago
        One rarely actually needs to shadow binaries. Some cases could indeed be covered by introducing an alias that binds the binary&#x27;s name to call a different copy of that binary.<p>You use shadowing to fix issues where you install some software that expects you to have a sane and ~recent version of some tool like git, but you don&#x27;t as your system provides that binary and unfortunately it is either not sane (not GENERALLY sane [while it could be sane for system scripts]) or not recent enough. In that case the program&#x27;s function would simply fail if it would call the system&#x27;s binary and you shadow the binary with your version to fix that.<p>&gt; adding your script directory in front of the PATH<p>That&#x27;s a poor advice for the scripts you call relatively frequently. Instead, (as a general approach, we aren&#x27;t discussing some particular script) don&#x27;t use shadowing for scripts: just pick a non-conflicting script name and append the script&#x27;s dir to $PATH.
        • Joker_vD6 hours ago
          &gt; That&#x27;s a poor advice for the scripts you call relatively frequently.<p>Why? It protects you from someone else (<i>cough</i> updated packages introducing new commands <i>cough</i>) picking a name you already use.
          • mathfailure2 hours ago
            Because it&#x27;s useless extra typing. People try to narrow commands down to two fucking chars and you suggest to type the whole goddamn path!
    • ri0t6 hours ago
      TIL: Backslash overrides alias - wow!<p>Thanks, mathfailure - this genuinely improves my life!
      • mixmastamyk5 hours ago
        ‘command grep’ also works in several shells. A little longer but looks good in scripts etc.
    • hinkley3 hours ago
      When “I” means me then this usually works for me. But when “I” becomes “we”, sometimes this goes off the rails because someone introduces a bin with breaking changes that silently fucks up projects that dev doesn’t really know about, or forgot about.<p>Call it the Chesterton’s Fence of ‘which’.
    • wasmainiac3 hours ago
      I would recommend against overriding standard system binaries, you could break compatibility on your system with scripts that depend on those binaries. I just use an abbreviation like rg=“grep -RE”
      • RadiozRadioz3 hours ago
        Why are those scripts running in interactive login shells? If they are influenced by the configuration of profile, then the scripts are bad.
        • wasmainiac3 hours ago
          That’s true, but I would still call overloading system binaries bad practice. Your making yourself foot gun.
          • mathfailure2 hours ago
            No, in fact he is correct: system scripts won&#x27;t pick up your overrides configured via your shell&#x27;s rc scripts.
            • wasmainiac30 minutes ago
              I said he was right, but in your case you are wrong. Your shell loads thr profile script for login shells, but will load your bashrc regardless of login or not<p>Excluding this argument, overloading system commands is still bad practice lol. Have you ever logged into an embedded device and had a busy box environment? the behaviour of some utilities can be different from what you expect for utilities of the same name.
    • CGamesPlay10 hours ago
      I do this, and routinely shadow commands with my own wrappers to do things like set environment variables.<p>And then there’s Claude. It deletes whatever it finds at ~&#x2F;.local&#x2F;bin&#x2F;claude, so I have to use a shell function instead to invoke the full path to my wrapper.
      • e1g10 hours ago
        You can use an alias, which takes priority over $PATH. e.g. I have this in .zhsrc to override the &quot;claude&quot; executable to run it in the OS sandbox:<p><pre><code> alias claude=&quot;sandbox-exec -f ~&#x2F;agents-jail.sb ~&#x2F;.local&#x2F;bin&#x2F;claude --dangerously-skip-permissions&quot;</code></pre>
        • plagiarist9 hours ago
          How does your sandbox ruleset look? I&#x27;ve been using containers on Linux but I don&#x27;t have a solution for macOS.
          • e1g7 hours ago
            Here&#x27;s my ruleset <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;eugene1g&#x2F;ad3ff9783396e2cf35354689cc6473e1" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;eugene1g&#x2F;ad3ff9783396e2cf35354689cc6...</a><p>My goal is to prevent Claude from blowing up my computer by erasing things it shouldn&#x27;t touch. So the philosophy of my sanboxing is &quot;You get <i>write access</i> to $allowlist, and <i>read access</i> to everything except for $blocklist&quot;.<p>I&#x27;m not concerned about data exfiltration, as implementing it well in a dev tool is too difficult, so my rules are limited to blocking highly sensitive folders by name.
            • icedchai2 hours ago
              That&#x27;s neat. I&#x27;m going to base my ruleset off of yours. I&#x27;ve been messing around with claude more and more lately and I need to do <i>something.</i>
    • 11223311 hours ago
      Any severe side effects so far? Have you set PATH up somehow so it is effect only on interactive prompt, and not in the launched processes?<p>Because I cannot imagine much 3rd party scripts working with random flags added to core tools
      • deredede10 hours ago
        I also do this.<p>Random flags added to core tools are done with aliases, which do not affect the launched processes, not by shadowing them in ~&#x2F;bin. Shadowing in ~&#x2F;bin are for cases where a newer (compared to the system-wide version) or custom version of a tool is needed.
      • mathfailure7 hours ago
        Not really, since if one usually does that - they probably understand the possible consequences and don&#x27;t shadow whatever they like, but do it carefully.<p>On MacOS I shadow that way just curl and git binaries to the versions installed from homebrew and nothing has broken (yet). I know that tar on MacOS is also a weirdo that I&#x27;d rather shadow with the homebrew&#x27;s gtar, but their args are different and I of course understand that there&#x27;s a high probability of something in system to be bound to mac&#x27;s version of tar, so here I better remember to use &#x27;sane&#x27; tar as gtar or use an alias (instead of shadowing the binary) for tar to use gtar (because aliases are for users, not for system scripts&#x2F;processes).<p>And on my home desktop&#x27;s Debian - I don&#x27;t even use shadowing of binaries at all (never needed it).<p>Also, I just realized: I change PATH env via my shell&#x27;s rc script (~&#x2F;.zshrc), so I probably could worry even less about shadowing system binaries (like tar on MacOS) possibly breaking things.
    • alance10 hours ago
      Just on your first suggestion, this also means that if a person or process can drop a file (unknown to you) into your ~&#x2F;bin&#x2F; then they can wreak havoc. Eg they can override `sudo` to capture your password, or override `rm` to send your files somewhere interesting, and so on.<p>Btw on the second suggestion, I think there&#x27;s a command named `command` that can help with that sort of thing, avoids recursive pitfalls.
      • functionmouse10 hours ago
        That would require someone to already want to sabotage me in particular, learn my private workflows, and also have write access to my home folder. At that point, All is Lost.<p>Don&#x27;t tell people to sacrifice agency for apocalypse insurance that doesn&#x27;t work, lol
      • latexr9 hours ago
        If someone can drop a file in your ~&#x2F;bin, they can also edit your shell’s startup files to add their malicious command.
      • wtetzner9 hours ago
        I think it&#x27;s already game over if they have access to your home directory. They can also edit your path at that point.
      • dieulot8 hours ago
        The issue of rootless malicious command overrides is solved by typing the whole path, such as &quot;&#x2F;bin&#x2F;sudo&quot;.
        • mathfailure7 hours ago
          No, don&#x27;t do that as a precaution. As others have already answered correctly - it&#x27;s too late to worry about such things if a malicious agent has write access to your ${HOME} dir.
      • znpy10 hours ago
        While true, what you describe is very unlikely to happen and most definitely won’t happens on systems where i’m the only users.
    • pmarreck9 hours ago
      I do the same thing, but I also have a command that shows me what functions or scripts might be shadowing other scripts
      • e408 hours ago
        Care to share?
        • lowmagnet7 hours ago
          the sibling answer but with `-a` before command name, will display all path hits for a command.
        • cluckindan7 hours ago
          <p><pre><code> which &lt;commandname&gt;</code></pre>
          • e407 hours ago
            Seemed like it was more than that, but the comment is ambiguous. I took it to mean &quot;show me all the commands which are shadowed&quot; not &quot;is this command shadowed&quot;...
    • chrisjj11 hours ago
      &gt; If I introduce an executable with a name, that overrides a system one<p>... and breaks existing scripts that reference the system one, right?
      • amszmidt10 hours ago
        Not if it is an alias.
        • hk__29 hours ago
          But yes if it’s another executable.
    • fragmede11 hours ago
      curious if you&#x27;re customizing anyway, why not use eg ripgrep?
      • mathfailure8 hours ago
        Others have already given valid answers: grep is not ripgrep [their params don&#x27;t match], so it&#x27;s a bad idea to alias &#x27;grep&#x27; to use ripgrep. But it&#x27;s okay to alias &#x27;ripgrep&#x27; (or &#x27;rg&#x27; or whatever) to use ripgrep with some args.
      • wtetzner9 hours ago
        repgrep&#x27;s CLI options and general behavior are different from grep. I tend to use both for different things.
      • llimllib10 hours ago
        Not OP, but I use ripgrep and customize it with an alias as well, so it applies equally there
  • bilbo-b-baggins30 minutes ago
    Love this thread reminding me that most experts in computers are unhinged lunatics doing convoluted and tortured things on a daily basis that they consider perfectly normal and even convenient.
  • jkercher9 hours ago
    Tangentially related. Don&#x27;t ever put &quot;.&quot; in your PATH. I used to do this to avoid typing the &quot;.&#x2F;&quot; to execute something in my current directory. BAD IDEA. It can turn a typo into a fork bomb. I took down a production server trying to save typing two characters.
    • marcosdumay5 hours ago
      It used to be very common to &quot;own&quot; a unix system by adding a `ls` binary in some folder and waiting for an administrator to run it.
      • bobbylarrybobby1 hour ago
        Why would this own a server? ls lists itself, but listing itself shouldn&#x27;t cause it to run again? Where&#x27;s the infinite loop that brings the server down?
        • suprjami1 hour ago
          I think parent comment means &quot;cp badthing ls&quot; and leave it latent for someone to run. Maybe $PATH has CWD first for convenience?
    • mathfailure7 hours ago
      I like to follow my own convention where I name files with shell scripts with an extension: .sh for POSIX-compatible scripts, .bash for scripts with bashisms or .zsh for scripts with zshisms.<p>If I ever wanted to achieve what you initially wanted to achieve - I could use something like<p>alias -s sh=sh<p>alias -s bash=bash<p>alias -s zsh=zsh<p>Just like I do bind .txt and .conf to &#x27;less&#x27;, .pdf to &#x27;qpdf&#x27;, .json to &#x27;ijq&#x27;, video formats to &#x27;mpv&#x27; and so on.
    • zahlman7 hours ago
      Might I ask exactly what the typo was?
    • lanyard-textile7 hours ago
      Elaborate?? &quot;.&quot; has been at the end of my PATH for like 20 years.
      • ahepp5 hours ago
        Just to save the trouble of writing &#x27;.&#x2F;&#x27;?
    • zelphirkalt7 hours ago
      Why does this go wrong and in what situation?
      • necovek4 hours ago
        Somebody mentioned it elsewhere, but it is a security risk: if you end up in a directory that&#x27;s not under your control, and you do a &quot;ls&quot;, it might execute &quot;.&#x2F;ls&quot; instead of &#x2F;usr&#x2F;bin&#x2F;ls, and that can be doing anything, including piping your ~&#x2F;.ssh&#x2F;id_* to a remote server.<p>This can also happen by downloading something off the internet (git clone, or tar xz foo.tar.gz), or on a multi-user system (eg. someone can put any of these common commands into &#x2F;tmp&#x2F; and wait for you to drop into it and try a &quot;ls&quot; there) — if you have any untrusted content anywhere, you are exposed.
        • mathfailure2 hours ago
          &gt; if you end up in a directory that&#x27;s not under your control, and you do a &quot;ls&quot;, it might execute &quot;.&#x2F;ls&quot; instead of &#x2F;usr&#x2F;bin&#x2F;ls,<p>Not if if you APPEND the dot path to the PATH env: the system traverses the dirs specified in the PATH env from left to right and stops at first match. Your system&#x27;s ls binary is in the dir that&#x27;s to the left of your &#x27;.&#x27; dir.
      • Kiboneu6 hours ago
        A trip down the recursion hole. Also, scripts will inherit the relative path so they will have different absolute paths from each other. Seems easier to just type .&#x2F; so it&#x27;s kinda funny in a &quot;UNIX haters handbook&quot; kind of way, but it&#x27;s not even a fault in linux&#x27;s command interface in that case. We&#x27;ve all been there.<p>Oh, that&#x27;s without even going into the security risks and loss of portability.
      • renewiltord6 hours ago
        Presumably a script that aliases a common thing or something and then it uses the same. E.g. someone adds .&#x2F;sed that has some default params and calls sed. You’re intended to call it with ~&#x2F;not-in-path&#x2F;defaulted&#x2F;sed and it is supposed to then call sed but instead calls itself if it’s earlier in the path hierarchy.<p>Might even be as simple as “detect if I’m running gnu sed or bsd sed and use the appropriate one”. Obviously you can not have this problem by being smart about other things but defense in depth right?
        • mathfailure2 hours ago
          Not if if you APPEND the dot path to the PATH env: the system traverses the dirs specified in the PATH env from left to right and stops at first match. Your system&#x27;s sed binary is in the dir that&#x27;s to the left of your &#x27;.&#x27; dir.
    • Kiboneu8 hours ago
      lol. What a beautiful footgun — for such a tiny optimization.
  • ljouhet11 hours ago
    Most of my aliases contain `--` for the same reason, `git--progress`, `grep--rIn`, `nvidia--kill`, `ollama--restart`, `rsync--cp`, `pdf--nup`...<p>Easy autocomplete, I know there won&#x27;t be any collision, and which command is mine.
    • mathfailure7 hours ago
      Kinda makes no sense to me: so you don&#x27;t use &#x27;--&#x27; as a prefix, you use it in the middle of an alias, so you first have to autocomplete, say, &#x27;gi&#x27; not to &#x27;git&#x27; but to &#x27;git--progress&#x27;. What does that alias do? Doesn&#x27;t it call git with some args? If so - why not just alias it to git?
    • finghin10 hours ago
      Great hack!
  • michaelcampbell9 hours ago
    Glad it worked for OP, but I&#x27;ve never once in 30+ years of this had a conflict that did something I didn&#x27;t want. ~&#x2F;bin&#x2F; is early in my PATH, and for a good reason. Things I put in there I want to take precedence, so I use this to purposely override provided bins. (Though I can only think of one time I wanted to do that, too.)
  • caeruleus11 hours ago
    Prefixing commands solves the namespace problem and discoverability (at least partly). I use a slightly more sophisticated method, which helps me remember which custom utilities are available and how to use them: sd [1], a light wrapper written for zsh that, in addition to namespaces, provides autocompletion, custom help texts + some other QoL enhancements. Can definitely recommend if you&#x27;re looking for something a bit more fancy.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;ianthehenry&#x2F;sd" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ianthehenry&#x2F;sd</a>
  • nh26 hours ago
    Worth pointing out that with Nix&#x2F;NixOS this problem doesn&#x27;t exist.<p>The problem in other distros is that if you prefix PATH so that it contains your executable &quot;foo&quot;, and then run a program that invokes &quot;foo&quot; from PATH and expects it to do something else, the program breaks.<p>With Nix, this problem does not exist because all installed programs invoke all other programs not via PATH but via full absolute paths starting with &#x2F;nix&#x2F;store&#x2F;HASH...
    • ahepp5 hours ago
      The &quot;solution&quot; of only ever using full absolute paths works on any unix system, doesn&#x27;t it?
      • aidenn04 hours ago
        Yes with a but:<p>NixOS simultaneously smooths the path to using absolute paths while putting some (admittedly minor) speed-bumps in the way when avoiding them. If you package something up that uses relative paths it will probably break for someone else relatively quickly.<p>What that means is that you end up with a system in which absolute paths are used almost everywhere.<p>This is why the killer feature of NixOS isn&#x27;t that you <i>can</i> configure things from a central place; RedHat had a tool to do that at least 25 years ago; it&#x27;s that since most of &#x2F;etc&#x2F; is read-only, you <i>must</i> configure <i>everything</i> from a central place, which has two important effects:<p>1. The tool for configuring things in a central place can be much simplified since it doesn&#x27;t have to worry about people changing things out from under it<p>2. Any time someone runs into something that is painful with the tool for configuring things in a central place, they have to improve the tool (or abandon NixOS).
    • ablob6 hours ago
      So if I want to use grep in a small script, do I have to write:<p>&#x2F;nix&#x2F;store&#x2F;grep-hash -flags files | &#x2F;nix&#x2F;store&#x2F;head-hash<p>instead of: &quot;grep -flags files | head&quot;?
      • aidenn03 hours ago
        If it&#x27;s a one off, you just use something like &quot;nix shell&quot; to add it to your path for running the script.<p>For non one-off sorts of things, you would substitute in the nix expression &quot;${gnugrep}&#x2F;bin&#x2F;grep&quot; the &quot;${gnugrep}&quot; will expand to &quot;&#x2F;nix&#x2F;store&#x2F;grep-hash&quot; and also make a dependency on the gnugrep package, so that the grep install won&#x27;t get garbage-collected as long as your package is still around.<p>Here&#x27;s an example[1] from a package expression for e-mail client I use, which will shell out to base64 and file. Upstream relies on these two programs being in $PATH, but this replaces the string used for shelling out with the absolute path in the nix store.<p>For shell scripts, I&#x27;ll just do something like this near the top:<p><pre><code> GREP=&quot;${GNU_GREP:-$(command -v grep)}&quot; </code></pre> Then I use &quot;$GREP&quot; in the script itself, and develop with grep in my path, but it&#x27;s trivial to prepend all of my dependencies when I bundle it up for nix.<p>1: <a href="https:&#x2F;&#x2F;github.com&#x2F;NixOS&#x2F;nixpkgs&#x2F;blob&#x2F;master&#x2F;pkgs&#x2F;by-name&#x2F;no&#x2F;notmuch-bower&#x2F;package.nix#L29-L30" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;NixOS&#x2F;nixpkgs&#x2F;blob&#x2F;master&#x2F;pkgs&#x2F;by-name&#x2F;no...</a>
      • xaduha6 hours ago
        <p><pre><code> [user@nixos:~]$ which grep &#x2F;run&#x2F;current-system&#x2F;sw&#x2F;bin&#x2F;grep [user@nixos:~]$ ls -l &#x2F;run&#x2F;current-system&#x2F;sw&#x2F;bin&#x2F;grep lrwxrwxrwx 1 root root 65 Jan 1 1970 &#x2F;run&#x2F;current-system&#x2F;sw&#x2F;bin&#x2F;grep -&gt; &#x2F;nix&#x2F;store&#x2F;737jwbhw8ji13x9s88z3wpp8pxaqla92-gnugrep-3.12&#x2F;bin&#x2F;grep </code></pre> Basically, it is still in your environment, so I don&#x27;t see how he can claim that this problem doesn&#x27;t exist in Nix, unless you use flakes like a proper Nix afficionado.
        • aidenn03 hours ago
          Yes, the original comment that this problem doesn&#x27;t exist in Nix is wrong for a typical user environment.<p>It does contain the issue a bit though:<p>I&#x27;m running isync in a systemd service, yet the program &quot;mbsync&quot; is not in my path. I have several services installed, yet their programs aren&#x27;t in my path. My e-mail client shells out to &quot;file&quot; for mime-type verification, yet &quot;file&quot; is not in my path.<p>Run &quot;compgen -c |wc -l&quot; to get a list of commands; its over 7000 on my Ubuntu system and right around 2000 on my NixOS system.<p>As an aside, the packages that put the most executables in my path are probably going to be in the path for most NixOS installs (231 just for coreutils+util-linux):<p><pre><code> 27 &#x2F;nix&#x2F;store&#x2F;csxa6mi2mpjl9vqxbv2j0bha6sz6nbjw-cups-2.4.14 31 &#x2F;nix&#x2F;store&#x2F;334afxah19b3hr6ll93pfxlcyhhh2vws-pipewire-1.4.9 31 &#x2F;nix&#x2F;store&#x2F;h2jsb5i4yfblr2f3ac2c7zpmlmj7zjym-perl-5.40.0 33 &#x2F;nix&#x2F;store&#x2F;914x32c982bs3i1998yxvkg9svm3ycr5-shadow-4.18.0 33 &#x2F;nix&#x2F;store&#x2F;a6s3hzj3b2z6rsyfkjyxwn265iyfl2gn-mtools-4.0.49 33 &#x2F;nix&#x2F;store&#x2F;jky7jszaci5n7g426wf6nsg5dmik9nfw-kbd-2.9.0 37 &#x2F;nix&#x2F;store&#x2F;2v1l6mqz0d7mfpp4ksw2048v3g0a1a19-hplip-3.25.2 45 &#x2F;nix&#x2F;store&#x2F;90wlc37ljr6rpy2lan46bp0gq19vbgl5-iptables-1.8.11 48 &#x2F;nix&#x2F;store&#x2F;1byhxs7b28grh8s15jc2dvs2zg36swjb-lvm2-2.03.35-bin 61 &#x2F;nix&#x2F;store&#x2F;9xwxjkrwxjsvc5gs1l0syr4wbfvvvvcn-bluez-5.84 64 &#x2F;nix&#x2F;store&#x2F;zf8qy81dsw1vqwgh9p9n2h40s1k0g2l1-systemd-258.2 72 &#x2F;nix&#x2F;store&#x2F;1igrj9w84w7s3r80l3nkxcqwd84sw9mz-qemu-10.1.2 106 &#x2F;nix&#x2F;store&#x2F;v4q3154vdc83fxsal9syg9yppshdljyk-coreutils-full-9.8 125 &#x2F;nix&#x2F;store&#x2F;3c6r8gh8zrqw8xmncmlj9vivz9rz6r30-util-linux-2.41.2-bin</code></pre>
          • xaduha2 hours ago
            True enough, but in my experience it&#x27;s not really much of a problem because if I&#x27;m not doing Nix, then I&#x27;m doing containers which are widely available.<p>What can be a problem is muscle memory, when you expect it to autocomplete one way and it doesn&#x27;t because something you want now shares first two or three letters with something else in your path. That&#x27;s where FIGNORE comes in.
  • alzee10 hours ago
    Using commas in filenames feels kind of weird to me, but I do use a comma as the initiator for my Bash key sequences. For example: ,, expands to $ ,h expands to --help ,v expands to --version ,s prefixes sudo<p>You put keyseqs in ~&#x2F;.inputc, set a keyseq-timeout, and it just works.
    • zahlman7 hours ago
      You could also do this sort of thing with XCompose, yes?
    • pmarreck9 hours ago
      would an alias just work in this use-case?
      • listeria7 hours ago
        Global aliases are a zsh feature and not avaliable in bash. So if you want:<p><pre><code> openssl ,v</code></pre> to expand to...<p><pre><code> openssl --version</code></pre> readline seems like the way to go.<p>Then again most of the examples OP gave are usually available as short options, and aliasing ,s to sudo is certainly possible. So the only one which makes sense to me is ,,=$. But it&#x27;s probably not worth the trouble to my muscle memory.
    • pmarreck9 hours ago
      also. did you mean .inputrc ?
  • pkulak7 hours ago
    There’s this program on nix that lets you type a comma, then any application name that exists anywhere in the Nix repos. It then downloads that app and runs it once, without “installing” it. Sometimes I find myself running something dozens of times this way before I realize it should probably be in my config.
    • xyzzy_plugh7 hours ago
      <a href="https:&#x2F;&#x2F;github.com&#x2F;nix-community&#x2F;comma" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nix-community&#x2F;comma</a>
      • Arcuru6 hours ago
        I&#x27;m not sure I&#x27;ll ever understand why they replaced their working ~50 line shell script with a Rust program that just shells out to the same nix-* commands. I appreciate that there are some safety benefits, but that program is just not complex enough to benefit.
        • rafram4 hours ago
          Because it&#x27;s &quot;a proper language&quot; [1]. Not to mention webscale!<p>It does seem to do some more complex stuff now that would&#x27;ve been annoying, but not impossible, to write as a shell script.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;nix-community&#x2F;comma&#x2F;pull&#x2F;19" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nix-community&#x2F;comma&#x2F;pull&#x2F;19</a>
        • aidenn03 hours ago
          Shell is already memory safe, so there&#x27;s not even &quot;we replaced C&quot; to lean on.
  • sevg12 hours ago
    This is one of those ideas that is so simple and elegant that it makes you think “why did I never think of doing this?!”<p>Neat trick! I don’t think I’ll namespace <i>everything</i> this way, because there’s some aliases and commands I run so often that the comma would get annoying, but for other less frequently used helper scripts then this will be perfect!
    • bonzini11 hours ago
      I do something similar with build trees, naming them +build, +cross-arm etc.<p>This convention was suggested by the GNU Arch version control system years ago (maybe 20??), but it&#x27;s really useful for the same tab completion reason and I have kept it for almost two decades, even when I switched to git.
      • amszmidt10 hours ago
        It was suggested by Tom Lord (RIP), who used it heavily long before he wrote GNU Arch.<p>File names or directories starting with a comma where considered “junk”, and ones with a plus sign I think where considered “precious”.
    • pjerem11 hours ago
      Maybe then try ending your commands with a comma so that you don’t break first-char autocomplete !
      • stavros11 hours ago
        But that&#x27;s the killer feature for me! I always forget the little commands I&#x27;ve written over the years, whereas a leading comma will easily let me list them.
  • tomcam11 hours ago
    <p><pre><code> Every tool and shell that lay in arm&#x27;s reach treated the comma as a perfectly normal and unobjectionable character in a filename. </code></pre> WTF. After 40 years maybe I should have figured that one out.
    • pm21511 hours ago
      It&#x27;s not a completely non special character: for instance in bash it&#x27;s special inside braces in the syntax where &quot;&#x2F;{,usr&#x2F;}bin&quot; expands to &quot;&#x2F;bin &#x2F;usr&#x2F;bin&quot;. But the need to start that syntax with the open brace will remind you about the need to escape a literal comma there if you ever want one.
    • xyzzy_plugh7 hours ago
      You may enjoy learning about the [ binary.
    • layer89 hours ago
      You never used CVS&#x2F;RCS with its “,v” files?
    • mike-the-mikado10 hours ago
      Until someone forces you to use a file system that cannot tolerate commas...
      • layer89 hours ago
        Which file system would that be?
        • icedchai2 hours ago
          Many early file systems like the original FAT, RSX-11, VMS ODS-2 ... Probably not a concern for anything in the past 30 years.
    • XCSme9 hours ago
      What about using the filename in arrays in bash&#x2F;sh?
      • layer89 hours ago
        But Bash arrays don’t use comma, what’s the problem?
        • XCSme9 hours ago
          Oh, that might be true, I do remember encountering some escaping issues when creating a more complex POSIX (or bash) script that involved lists and iterating through stuff.<p>I see Bash only uses commas in Brace expansions:<p>file{1,2,3}.txt # file1.txt file2.txt file3.txt<p>I guess it would only be a problem if you want to expand<p><pre><code> file,.txt file,,.txt file,,,.txt</code></pre>
          • XCSme9 hours ago
            Imagine seeing this code:<p><pre><code> echo file{&quot;,&quot;,&quot;,,&quot;,&quot;,,,&quot;}.txt</code></pre>
            • mathfailure7 hours ago
              Ah, I see you&#x27;re a man of culture as well!
        • pmarreck9 hours ago
          Have you met Bash? It’s a shrine to space-delimited everything lol
          • layer89 hours ago
            I reworded my comment for clarity now.
  • macintux8 hours ago
    This has been a popular topic nearly every time the post makes the HN front page.<p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40769362">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40769362</a> (2024, 169 comments)<p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31846902">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31846902</a> (2022, 123 comments)<p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988</a> (2020, 90 comments)
  • 1vuio0pswjnm711 hours ago
    I use a different prefix character, e.g. &quot;[&quot;, but I have been doing this for years<p>I started using a prefix because I like very short script names that are easy to type<p>I prefer giving scripts numbers instead of names<p>Something like &quot;[number&quot;<p>I use prefixes and suffixes to group related scripts together, e.g., scripts that run other scripts<p>I have an executable directory like ~&#x2F;bin but it&#x27;s not called bin. It contains 100s of short scripts
    • 1vuio0pswjnm74 hours ago
      I have zero problems with the terseness of the k language, the names of the source files nor the source code they contain<p>I find brevity easier to work with. I wish all software was like that<p>I like the shell (ash not bash). I like assembly language<p>I have to &quot;adjust&quot; to verbosity, and sometimes I honestly can&#x27;t, it&#x27;s paralyzing to the brain, terseness feels more natural<p>Why not name scripts in natural language like an LLM prompt perhaps (I don&#x27;t use LLMs so pardon the ignorance), with spaces and punctuation<p>Bash allows it<p><pre><code> echo echo hello &gt; &quot;dear computer, please output the word \&quot;hello\&quot;. thank you&quot; chmod +x &quot;dear computer, please output the word \&quot;hello\&quot;. thank you&quot; &quot;dear computer, please output the word \&quot;hello\&quot;. thank you&quot; </code></pre> That might make sense if I was using the scripts to communicate with a another person, or if I intended other persons besides me to use the scripts<p>But neither of those things is true. The scripts are for communicating with a computer and are intended to be used only by me<p>UNIX allows anyone to rename any file to whatever they want. The UNIX user is free to pursue their own preferences in naming, whatever those may be
    • mathfailure7 hours ago
      &gt; I prefer giving scripts numbers instead of names<p>&gt; Something like &quot;[number&quot;<p>&gt; It contains 100s of short scripts<p>So you call scripts like [1 [2 [3 [4 ... and remember what each one of them does? If yes - that&#x27;s nuts, I&#x27;d visit a doctor.
      • 1vuio0pswjnm71 hour ago
        &quot;..., I&#x27;d visit a doctor&quot;<p>But I&#x27;m not you
    • feelamee10 hours ago
      do you publish dotfiles and scripts anywhere? I&#x27;m interested to see them
    • renewiltord5 hours ago
      This is utterly unhinged. I freaking love it. It reminds me of the old joke about prisoners and numbers for jokes (Stanislaw Lem has a similar concept in a book):<p><i>A prisoner, new to a particular cell block, was surprised to discover that his fellow inmates passed much of their day by calling out numbers, after which they would laugh heartily for a few moments. Every few minutes an inmate would call out a number and everyone would laugh, and then, after a few moments of silence, someone else would call out a number, and once again laughter. The inmate asked one of the other inmates whom he&#x27;d come to know to explain this strange behavior to him.<p>&quot;It&#x27;s simple&quot;, came the reply. &quot;We know all of our jokes by heart, and there&#x27;s really no reason to tell them at lenght. Instead, we simply call them out by number.&quot;<p>Though this was strange to him, the new inmate thought he&#x27;d join in on the fun. After a few weeks listening to the jokes, he took some initiative and called out &quot;number 27!&quot;. But nobody laughed. This seemed very strange to him, since he&#x27;d heard others call out that same number, with everyone laughing afterwards. After waiting and waiting, with still no laughter, he finally asked: &quot;why is it that when others call out that joke you laugh, and when I called it, nobody laughed?&quot;.<p>The reply promptly came: &quot;You told it wrong&quot;.</i>
  • impoppy11 hours ago
    Why so many people use ~&#x2F;bin&#x2F;? What’s wrong with ~&#x2F;.local&#x2F;bin?
    • mathfailure7 hours ago
      People tend to want some separation between what&#x27;s theirs and what&#x27;s others. Other programs&#x2F;scripts quite often put something into ~&#x2F;.local&#x2F;bin, so it&#x27;s not yours actually, it&#x27;s theirs.
    • 1313ed0110 hours ago
      Random things are installed in ~&#x2F;.local&#x2F;bin. In ~&#x2F;bin I have only what I put there.
      • mixmastamyk4 hours ago
        Python and rust (for example) package managers install user wide tools there.
    • gucci-on-fleek8 hours ago
      I personally use both, each for different purposes.<p>I snapshot my entire home directory every hour (using btrfs+snapper), but I exclude ~&#x2F;.local&#x2F; from the snapshots. So I use ~&#x2F;.local&#x2F;bin&#x2F; for third-party binaries, since there&#x27;s no reason to back those up; and ~&#x2F;bin&#x2F; for scripts that I wrote myself, since I <i>definitely</i> want to back those up.<p>This is a pretty idiosyncratic use though, so I&#x27;d be surprised if many other people treated both directories this way.
    • maleldil8 hours ago
      I use ~&#x2F;.local&#x2F;bin for installed programs, and ~&#x2F;bin for my own scripts.
    • aniou6 hours ago
      I prefer ~&#x2F;bin&#x2F; for my scripts, links to specific commands, etc.<p>~&#x2F;.local&#x2F;bin is tedious to write, when I want to see directory content and - most important - I treat whole ~&#x2F;.local&#x2F; as managed automatically by other services and volatile.
    • kps8 hours ago
      Personally I use ~&#x2F;opt&#x2F;<i>&#x2F;bin where ~&#x2F;opt is a ‘one stop shop’ containing various things, including a symlink to ~&#x2F;local and directories or symlinks for things that don&#x27;t play well with others (e.g. cargo, go), and an ~&#x2F;opt&#x2F;prefer&#x2F;bin that goes at the start of PATH containing symlinks to resolve naming conflicts.<p>(Anything that modifies standard behaviour is not in PATH, but instead a shell function present only in interactive shells, so as not to break scripts.)<p>Unix lore: Early unix had two-letter names for most common names to make them easy to type on crappy terminals, but no </i>one* letter command names because the easier were reserved for personal use.
      • lupire8 hours ago
        What&#x27;s the difference between opt and local?<p>I thought was for mixin externally provided systems like Homebrew, local is for machine or org-level customizations, and ~ is for user-level customizations.
        • kps8 hours ago
          &#x2F;opt showed up as a place for packaged software, where each package (directory) has its own bin&#x2F;, lib&#x2F;, man&#x2F;, and so on, to keep it self-contained rather than installing its files in the main hierarchy. ~&#x2F;opt is just a per-user equivalent, analogous to &#x2F;usr&#x2F;local vs ~&#x2F;.local.<p>The advantage of &#x2F;opt is that multi-file software stays together. The disadvantage is that PATHs get long.
    • pmarreck9 hours ago
      The latter is XDG.<p>~&#x2F;bin predates it.<p>And of course you can use both.
    • xorcist8 hours ago
      Why would you want to store your binaries in a hidden directory?<p>It kind of goes against the idea why dotfiles are dot-prefixed.
    • dark-star11 hours ago
      ~&#x2F;bin&#x2F; preceeds the XDG Base Directory Specification.<p>~&#x2F;.local was only invented around 2003 and gained widespread usage maybe 15 years or so ago...<p>People used ~&#x2F;bin already in the 90s ;-)
    • zhouzhao11 hours ago
      Nothing. I also use `~&#x2F;.local&#x2F;bin&#x2F;`
  • jph11 hours ago
    Clever hack! &lt;3 I also do namespacing yet in a different way.<p>I create a home directory &quot;x&quot; for executables that I want to manage as files, and don&#x27;t want on PATH or as alias.<p>To run foo: ~&#x2F;x&#x2F;foo<p>For example I have GNU date as ~&#x2F;x&#x2F;date so it&#x27;s independent of the system BSD date.
  • jmux25 minutes ago
    yes this is totally cursed but I kinda love the idea
  • vitorsr10 hours ago
    Nice although I think the ASCII comma <i>feels</i> wrong as part of a filename even if for purely aesthetic reasons.<p>If we want to stay within (lowercase) alphabetic Latin characters I think prefixing with the least common letters or bigrams that start a word (x, q, y, z, j) is best.<p>`y&#x27; for instance only autocompletes to `yes&#x27; and `ypdomainname&#x27; on my path.<p>Choosing a unique bigram is actually quite easy and a fun exercise.<p>And we can always use uppercase Latin letters since commands very rarely use never mind start with those.
    • diydsp9 hours ago
      Its some what natural to german spkrs who use a special set of double quotes to start a quote in print.
  • mromanuk11 hours ago
    It’s clever, but is not aesthetic. A comma feels unnatural in the fs.
    • layer89 hours ago
      So did the dot in dotfiles originally. You’ll get used to it if you want to.
    • mystifyingpoi11 hours ago
      It doesn&#x27;t have to be a literal file, it can be an alias.
      • lupire8 hours ago
        That doesn&#x27;t make it &quot;feel&quot; less &quot;unnatural&quot;.
  • synergy207 hours ago
    instead of using ~&#x2F;bin I use ~&#x2F;installed&#x2F;bin, sometimes I need build a command from source then install it, which might have share&#x2F; man&#x2F; etc so I can avoid installing them under the home dir.
    • mixmastamyk4 hours ago
      ~&#x2F;.local&#x2F; could work for this, and as another user mentioned easier to separate the back up.
  • falloutx11 hours ago
    Finally a post that is relevant to what I have been looking for quite some time.<p>Also, kudos to keeping it so concise and to the point, thats some prime writing.
  • ahepp5 hours ago
    One could set an env var to their local bin dir which is otherwise not in the path, like L=&#x2F;home&#x2F;ahepp&#x2F;.local&#x2F;bin, and then do $L&#x2F;mycommand. Doesn&#x27;t meet the OP&#x27;s requirement of no shift key.<p>Or prefix files in the local bin dir with a couple letters from your username, like &#x2F;home&#x2F;ahepp&#x2F;.local&#x2F;bin&#x2F;ah-mycommand
  • Tade010 hours ago
    As a non-native English speaker I just name them in my native language or using British English spelling.<p>I have a command named &quot;decolour&quot;, which strips (most) ANSI escape codes. Clear as day what it does, almost nobody uses this spelling when naming commands that later land as part of a distribution.
  • tasuki2 hours ago
    I never did this and never once experienced a name conflict.
  • nickelpro9 hours ago
    Properly manage PATH for the context you&#x27;re in and this is a non-issue. This is the solution used by most programming environments these days, you don&#x27;t carry around the entire npm or PyPI ecosystem all the time, only when you activate it.<p>Then again, I don&#x27;t really believe in performing complex operations manually and directly from a shell, so I don&#x27;t really understand the use-case for having many small utilities in PATH to begin with.
  • dcchuck9 hours ago
    I prefer all my custom commands as 1 letter.<p>On my most frequently used machine&#x2F;dev env this means -<p>e for vim<p>m for mise<p>n for pnpm<p>c for Claude<p>x for codex
    • maleldil8 hours ago
      r for uv run<p>j for just<p>I use fish abbreviations for this, as they expand to the full command in the shell history.
    • dddw9 hours ago
      d for deploy to production
  • grimgrin1 hour ago
    in vim i am very fond of two mapping prefixes: &lt;space&gt; and ,<p>they&#x27;re both so easy to reach for
  • matheus-rr8 hours ago
    This is one of those &quot;obvious in hindsight&quot; tricks. The comma prefix gives you a namespace that&#x27;s guaranteed to never collide with system binaries, shell builtins, or anything from a package manager.<p>I do something similar with my personal scripts — prefix them with a short namespace. The real win isn&#x27;t just avoiding collisions though, it&#x27;s tab completion. Type the prefix and tab, and you immediately see all your custom stuff without wading through hundreds of system commands.<p>The 2009 date on this is wild. Some of these simple unix conventions age better than most frameworks.
  • karolist11 hours ago
    Interesting, though I never had enough custom scripts to justify this, I prefer oh-my-zsh plugin style short aliases instead, i.e. <a href="https:&#x2F;&#x2F;github.com&#x2F;ohmyzsh&#x2F;ohmyzsh&#x2F;tree&#x2F;master&#x2F;plugins&#x2F;git" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ohmyzsh&#x2F;ohmyzsh&#x2F;tree&#x2F;master&#x2F;plugins&#x2F;git</a>
  • polyrand6 hours ago
    I do this, and it&#x27;s a huge quality of life improvement. No so much because of shadowing existing binaries, but for better command auto-complete. For example: I have a bunch of tmux utilities and all start with `,t` which is not a polluted command-name prefix compared to just `t`.<p>But I&#x27;m now facing the problem that LLM agents don&#x27;t like this, and when I instruct them to run certain tools, they remove the leading comma. It&#x27;s normally fixed with one extra sentence in the prompt, but still inconvenient.
  • dadandang12 hours ago
    ,Start all of <i>your</i> commands with a comma
    • zdc111 hours ago
      Should be titled <i>Prefix your script names with a comma</i>. Current title is a little clickbait-y through its ambiguity.
      • albert_e11 hours ago
        Agree.<p>I thought the title meant I should type ,ls instead of ls.
    • JamesTRexx10 hours ago
      ,sudo make me a sammich<p>Like so?
  • temporallobe10 hours ago
    I don’t think this is a terrible idea, though stylistically it bothers me. I suppose you could simply have a prefix command router that would essentially do the same thing. I also started using “task” recently and it’s been a game changer for my CLI life.
    • mogoh10 hours ago
      What is task?
      • alex-moon9 hours ago
        It is like make but designed specifically for the way non-C(++) users - people like me for example adding scripts like &quot;make run&quot; and &quot;make build&quot; to my node&#x2F;python&#x2F;PHP&#x2F;etc repos - use it. It is great! I still don&#x27;t use it literally just because make is already installed on any *nix system I encounter day to day.
        • temporallobe2 hours ago
          Interesting, I have never compared make with task but I suppose there’s some overlap. My favorite feature is that it’s cross-platform. I do use it for performing complex builds (like chaining several environment setup and docker compose commands, etc.). Of course you could do this with shell scripts, but this adds a layer of abstraction.
        • renewiltord5 hours ago
          I used task previously and now use mise for it since I have a mise version file usually anyway.
  • Dove9 hours ago
    In many contexts in which I am trying to deconflict namespaces, I use my initials. I hadn&#x27;t thought about it in this particular context, though now that I do, it seems fortunate that I am ced rather than sed.
  • elhosots8 hours ago
    I think its a fairly good idea - but for myself, i had already mapped csh’s default history character (!) to a comma (,) for the same reason - no shift key to invoke.
    • mixmastamyk4 hours ago
      csh? I used the enhanced tcsh on Irix in the 90s.
  • tezza10 hours ago
    This is a really good practical step if you worry about name collisions<p>quick, easy and consistent. entirely voluntary.<p>Bravo
  • moritzwarhier5 hours ago
    Why not just start every alias or script with ë or something?
    • ezfe5 hours ago
      Comma is easier to type and less visually distracting
      • moritzwarhier5 hours ago
        makes sense, article mentions not wanting composite keys. There goes my sarcasm.<p>However, I&#x27;d advocate for an ë key then.
  • skerit10 hours ago
    I would have never thought of that. Funny that a comma can be used like that.<p>Off-topic: What the hell is that font on this website? And why does the &quot;a&quot; look like that?
    • groue6 hours ago
      Gentium is a very beautiful font: <a href="https:&#x2F;&#x2F;software.sil.org&#x2F;gentium&#x2F;" rel="nofollow">https:&#x2F;&#x2F;software.sil.org&#x2F;gentium&#x2F;</a>
  • gugod11 hours ago
    I tried a variant or this idea so many years ago after I leaned git and rearranged some of my personal tools as subcommands (like git) of a single executable named &quot;dude,&quot;<p>It went weird pretty quickly...
    • renewiltord5 hours ago
      <p><pre><code> dude, whois my.car</code></pre>
    • eMPee5847 hours ago
      .. examples?
  • feelamee10 hours ago
    can someone explain security consideration of placing scripts into $HOME? Some time ago I moved all my scripts to &#x2F;usr&#x2F;local&#x2F;bin, because I feel that this is better from security perspective.
    • Galanwe10 hours ago
      There are no security implications, on the contrary.<p>It is objectively cleaner to keep your user scripts in your home, that way they are only in _your_ PATH, whereas putting them in &#x2F;usr&#x2F;[local&#x2F;]bin implicitly adds them to every [service] user on the machine, which I can see creating obscure undesired effets.<p>Not even mentioning the potential issues with packages that could override your scripts at install, unexpected shadowing of service binaries, setuid security implications, etc.
    • layer89 hours ago
      Someone with access to your home dir can also set your $PATH and aliases to anything they want, so I don’t see any extra security considerations here.
  • guilherme-puida11 hours ago
    (2009)
    • HelloUsername11 hours ago
      Previous discussions:<p>2024: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40769362">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40769362</a><p>2022: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31846902">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31846902</a><p>2020: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22778988</a>
  • luplex11 hours ago
    similarly, I start all my underscorends with an underscore
  • laughing_snyder11 hours ago
    &gt; Like many Unix users, I long ago created a ~&#x2F;bin&#x2F; directory in my home directory<p>`.local&#x2F;bin` seems to be much more common in my experience for this use case. And for good reason.
    • Levitating11 hours ago
      ~&#x2F;bin is actually created per default on OpenSUSE (though it&#x27;s removal has been discussed several times).
    • zhouzhao11 hours ago
      Unclutter your $HOME!
  • bronlund11 hours ago
    This is just brilliant. Thanks.
  • ndsipa_pomu11 hours ago
    I appreciate the idea, but the comma just looks horrible to me as part of a filename. I can imagine someone unfamiliar with the naming scheme to get confused.<p>I&#x27;d prefer to use underscore (when writing BASH scripts, I name all my local variables starting with underscore), but a simple two or three letter prefix would also work. I don&#x27;t like the idea of a punctuation prefix as punctuation usually has a specific meaning somewhere and including it as the first character in a filename looks wrong. (e.g. Comma is typically used as a list separator and it&#x27;s a bit of cognitive dissonance to see it not used in that context)
    • layer89 hours ago
      Underscore requires pressing Shift, however.<p>&gt; I don&#x27;t like the idea of a punctuation prefix as punctuation usually has a specific meaning somewhere and including it as the first character in a filename looks wrong.<p>So you don’t use dotfiles? ;)
      • necovek4 hours ago
        On non-English keyboards (Serbian&#x2F;Croatian&#x2F;Slovenian, but as they are based on QWERTZ, I imagine German and possibly others too), both &quot;+&quot; and &quot;-&quot; might not require pressing Shift either, and are much better characters than comma.
        • layer84 hours ago
          These are inconvenient for doing anything with the script files except invoking them, because these characters introduce command-line options.
          • necovek1 hour ago
            Which was the point here, wasn&#x27;t it? Script files that you will be commonly running and only editing rarely, I&#x27;d optimize for how easy they are to run, not operate other commands on them from within a shell.
      • ndsipa_pomu8 hours ago
        Well dotfiles demonstrate that punctuation can have a special meaning in filenames.<p>I&#x27;m not convinced by &quot;quicker to type&quot; arguments as that&#x27;s rarely the bottleneck, so I&#x27;m perfectly happy with using underscores in filenames and variables. I wouldn&#x27;t use underscore as the beginning character of a filename unless it had a specific meaning to me (e.g. temporary files), so I&#x27;d be more inclined to use a two or three character prefix instead.
        • layer88 hours ago
          For me it’s not about quickness, but about strain. Like in RSI.
    • eterps11 hours ago
      I use my_ as a prefix.
      • k3vinw7 hours ago
        That’s a more meaningful prefix than “,” at the expense of a couple more key strokes. I consider that to still be a win in the book of tab completions.<p>I would replace underscore with “-“ or “.”
        • ndsipa_pomu5 hours ago
          I&#x27;d warn against creating files starting with &quot;-&quot; as that can lead to unexpected results with tools if you forget to use &quot;--&quot; to end options. Nothing wrong with using &quot;my-&quot; as a prefix though.
      • ndsipa_pomu10 hours ago
        I used to use &quot;do&quot; as a prefix e.g. &quot;doBackup&quot;<p>Nowadays, I tend to skip using a personal prefix and just try to name commands with a suitable verb in front (e.g. &quot;backupMySQL&quot;) and ensure that there&#x27;s no name collisions.
      • JamesTRexx10 hours ago
        Whenever I see &quot;my&quot; as a prefix, it feels like such a childish &quot;my first Sony&quot; thing. I hate official sites using that.
        • SoftTalker6 hours ago
          This was actually the same feeling I had when I tried to learn perl. I just had a visceral dislike for &quot;my&quot; as the keyword to declare a local variable.
  • yunohn10 hours ago
    I read this blog a few years ago, and implemented it soon after with a refresh of my rc files and shortcuts. Gamechanger - has helped me every single day since. It’s easy to remember, autocompletes easily, and adds a little flair of personalization.
  • z0ltan8 hours ago
    [dead]