For one user account, I want to have some bash scripts, which of course would be under version control.

The obvious solution is just to put the scripts in a git repository and make ~/bin a symlink to the scripts directory.

Now, it seems on systemd systems ~/.local/bin is supposedly the directory for user scripts.

My question, is mostly, what are the tradeoffs between using ~/bin and ~/.local/bin as directory for my own bash scripts?

One simple scenario I can come up with are 3rd party programs which might modify ~/.local/bin and put their own scripts/starters there, similar to 3rd party applications which put their *.desktop files in ~/.local/applications.

Any advice on this? Is ~/.local/bin safe to use for my scripts or should I stick to the classic ~/bin? Anyone has a better convention?

(Btw.: I am running Debian everywhere, so I do not worry about portability to non systemd Linux systems.)

Solved: Thanks a lot for all the feedback and answering my questions! I’ll settle with having my bash scripts somewhere under ~/my_git_monorepo and linking them to ~/.local/bin to stick to the XDG standard.

  • Akatsuki Levi@lemmy.world
    link
    fedilink
    English
    arrow-up
    54
    arrow-down
    1
    ·
    3 days ago

    I use ~/.local/bin since by linux standard, ~/.local is a user-level /usr/local, which is a override level of /usr

    ~/bin ends up cluttering the home folder

    • Max-P@lemmy.max-p.me
      link
      fedilink
      arrow-up
      30
      arrow-down
      1
      ·
      3 days ago

      Another reason to use ~/.local is you can do things like

      ./configure --prefix=$HOME/.local
      make -j$(ncpu)
      make install
      

      And then you get your .local/bin, .local/share, .local/include, .local/lib and such, just like /usr but scoped to your user.

      and it should mostly just work as well.

      • Akatsuki Levi@lemmy.world
        link
        fedilink
        English
        arrow-up
        9
        arrow-down
        1
        ·
        3 days ago

        And if there’s other users in the machine, it doesn’t fuck things up for others Or if it ends up messing something up, it is user-scoped, so its a lot easier to fix than a bricked system

      • Ferk@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        2 days ago

        it may as well be a system managed folder at that point.

        In a way it is. But user-level system, as opposed to root-level system.

    • wolf@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      1
      ·
      3 days ago

      Another follow up question: Is there any documentation for the linux standard/convention of ~/.local/bin? My initial search about this resulted in nothing which I would call authoritative/definitive.

    • just_another_person@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      3 days ago

      Mostly this, but also, if you’re going to manage many scripts in a system for many users, revision control doesn’t help that. Either look at packaging them properly for your distro, or using something Ansible to distribute and manage their versioning on the system to make things easier on yourself.

          • Akatsuki Levi@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 day ago

            Can’t have supply chain issues if 90% of your stuff isn’t just a bunch of Docker containers running inside a Kubernetes mess

            Not saying that it doesn’t happen on bare metal stuff, but damm, is it a lot more prominent on sources like npm, pip and docker

            • just_another_person@lemmy.world
              link
              fedilink
              arrow-up
              2
              ·
              1 day ago

              Well…I mean the biggest obvious example in recent history is the xz-utils hack. There’s probably more like that out in the wild than most want to think about.

    • wolf@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 days ago

      Thanks! Do you just put the whole .local/bin under source control, do you link your scripts from somewhere else?