fish, the friendly interactive shell, is a commandline shell intended to be interactive and user-friendly.

fish is intentionally not fully POSIX compliant, it aims at addressing POSIX inconsistencies (as perceived by the creators) with a simplified or a different syntax. This means that even simple POSIX compliant scripts may require some significant adaptation or even full rewriting to run with fish.

Source

  • Marafon@sh.itjust.works
    link
    fedilink
    arrow-up
    34
    ·
    1 day ago

    I just switched to fish for the pretty colors and quality of life features. Anything I should keep in mind while using it as a Linux noob? I don’t even know who POSIX is lol.

    • Nalivai@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      5 hours ago

      zsh with oh-my-zsh addon can do the same amount of pretty colours and qol stuff, with the addition of being POSIX compliant. Not that fish is bad or anything, but you don’t want additional troubles with random incompatibility on top of the usual learning curve.

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      9
      ·
      21 hours ago

      “POSIX compliant shells” means shells that work with… Fuck how do I even describe this simplistically? A lot of scripts are ran by a program named “sh”. Sometimes it is bash, sometimes dash, but they’re all POSIX compliant which means they’ve got some standard things that most people expect.

      Using a non POSIX compliant shells will be okay, because programs trying to use “sh” will still work (unless you set something up wrong, which you’d probably have to go out if your way to do, so you’re probably fine).

      Genuinely the only downside to using a non POSIX compliant shell is that you won’t learn the standard stuff so you won’t be as good at writing and reading scripts. It’s truly not too big of a deal. Fish (non POSIX compliant) is what Arch (or at least Cachy) used by default. It’s been great. The defaults are useful. To get a similar experience with POSIX shells I typically have to use zsh with oh-my-zsh and some plugins. Fish does it all out of the box.

      So don’t worry about it!

      • Marafon@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        6 hours ago

        Hell yeah, I don’t really mess with scripts much yet but I do love to be non standard. Thanks for the run down!

    • somerandomperson@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      24
      ·
      1 day ago

      I HIGHLY recommend using bash and zsh as posix-compliant shells at the beginning, then if you want something different; you can use whatever the hell you want. Nushell, fish, etc.

      • woelkchen@lemmy.world
        link
        fedilink
        arrow-up
        12
        ·
        21 hours ago

        I HIGHLY recommend using bash and zsh as posix-compliant shells at the beginning

        Why? All the usual shell scripts don’t use Fish as interpreter.

        • somerandomperson@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          2
          arrow-down
          1
          ·
          9 hours ago

          No posix compliance is a headache. (Where the hell are my aliases!?) And also most scripts need to be executed in a posix-compliant shell.

          • Zozano@aussie.zone
            link
            fedilink
            English
            arrow-up
            10
            ·
            edit-2
            7 hours ago

            Most scripts need to be executed in a posix-compliant shell

            Simple. Just add #!/bin/bash to the start of your script and call it a day.

            Or use #!/usr/bin/env bash if you’re goated with the sauce. This won’t work if you’re not goated with the sauce.

            Those who are goated with the sauce know what’s up.

          • dreadbeef@lemmy.dbzer0.com
            link
            fedilink
            English
            arrow-up
            3
            ·
            edit-2
            7 hours ago

            why use aliases (they exist in fish) when you can use abbreviations and your history isnt determined by whatever you set your aliases up as? If you change an alias, your history does not reflect that. If you use abbreviations, your history is perfectly usable

      • interdimensionalmeme@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        22 hours ago

        WIll I be able to take my shell with on to every other computer I meet ? I mean, these things are tiny, but how portable are shells ? I don’t want to learn a bunch of useful custom commands and then become frustrated to do anything on every computer other than mine.

        That’s why I have a qwerty keyboard, I don’t want to become useless whenever I have to use a keyboard that isn’t my keyboard…

        • Ephera@lemmy.ml
          link
          fedilink
          English
          arrow-up
          4
          ·
          15 hours ago

          Fish is not the worst in this regard, because:

          • The defaults are pretty good, so you don’t typically need a config file for it to be usable.
          • As of version 4.0, Fish is (experimentally) available as a single executable for download from their GitHub page. So, even on hosts where you can’t install anything, you may still be able to copy that executable file onto there and use it.

          But there may still be situations where it’s annoying, like if you’re working in a container, then you likely don’t want to mount your fish executable every time.

          But I also have to say I don’t find it too big of a deal.
          I still use Bash for scripting (just throw a #!/bin/sh or #!/bin/bash at the top of your script, like you should anyways), and then for interactive use, not that much of the shell syntax comes into play anyways.
          And if I ever do need to copy a complex Bash command into an interactive shell, I can just run bash, then run the command in there and then exit back out.

        • somerandomperson@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          2
          ·
          edit-2
          22 hours ago

          Shell configs are hard to move. Some in $HOME/.config , some in .[idk]rc files, etc.

          It’s messy. Unless you write everything you modify. If you did not do that up to now…good luck moving shell configs.

          • AdamBomb@lemmy.sdf.org
            link
            fedilink
            English
            arrow-up
            5
            ·
            20 hours ago

            What? No they aren’t hard to move. They’re usually just one file. Copy to your new machine and done.

          • interdimensionalmeme@lemmy.ml
            link
            fedilink
            arrow-up
            1
            ·
            21 hours ago

            I have no shell configs of any kind because it seemed like everytime I used another computer, I would not have them and I would end up having the re-learn everything.

            So instead I google every command every time or ask chatgpt, like this

            I find it very annoying there’s isn’t a reliable way to use alias or shells, functions and stuff.

            • tal@lemmy.today
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              15 hours ago

              I have no shell configs of any kind because it seemed like everytime I used another computer, I would not have them and I would end up having the re-learn everything.

              What I do is store my dotfiles in a git repository, and leave symlinks to the files in that repository. Then, when I move to another computer, pulling over all my configuration consists of doing a git pull to pull the git repo over and then running a command to set up the symlinks on that new computer. I can also make changes and selectively push things in. Some things need to be specific to a computer, and those don’t go in.

              I use a homebrew script to set up the symlinks. A number of people use GNU stow for this.

              kagis for an example of someone using stow

              https://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html?round=two

              If you edit the symlinks in emacs (and I imagine vim), it picks up on the fact that they’re symlinks into a git repository and that they’re version-controlled.

              So, like:

              • Have a bare git repository on home machine, the “master” copy.

              • Every machine with an account has a non-bare dotfiles git repository checked out and symlinks pointing into that repo.

              • Make any changes on a given machine like you normally would, then git commit them to the local non-bare dotfiles git repo and push them to the master repository.

              • If setting up on a new machine, pull the git repository, and then run the command to set up the symlinks.___

    • RmDebArc_5@piefed.zipOP
      link
      fedilink
      English
      arrow-up
      13
      ·
      1 day ago

      Okay so first there was Unix. It was semi Open Source and a bunch of companies were making different versions that were becoming increasingly incompatible. That is why POSIX was created, it standardizes major parts of Unix. Linux is a Unix like operating system, meaning it functions similarly but doesn’t share any code. One thing that POSIX standardizes is the shell meaning there’s a standard how a loop works etc. Most shell on Linux like bash and zsh are POSIX compliant but some (like fish aren’t). This means a command that works one way in bash might work differently in fish. Basic stuff is mostly the same in my experience so if you’re not having any problems you shouldn’t worry about being POSIX compliant. If you want most of the same stuff but POSIX compliant checkout zsh. Fish provides documentation for adjusting your commands so I’d just ignore it until you run into a problem and then take a look at the docks