From bash to zsh and everywhere in between, show me yours and I’ll show you mines. Inspire others or get some feedback.

Simply copy & paste the output of alias in your terminal or add some comments to explain things for others.

Edit: Kbin users, click ‘More’ on a comment and use the fediverse link to read responses that have funky formatting

  • I_Am_Jacks_____@lemmings.world
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    1 year ago

    For system updates:

    [ -r /etc/os-release ] && . /etc/os-release
    case "$ID" in
      arch|archarm)
        if which paru > /dev/null 2>&1; then
          alias updates='echo Using paru; paru'
        else
          alias updates='echo Using pacman; sudo pacman -Syu --noconfirm'
        fi
        ;;
      debian|ubuntu)
        alias updates='echo Using apt dist-upgrade; sudo apt update && sudo apt dist-upgrade -y'
        ;;
    esac
    
    • ShittyBeatlesFCPres@lemmy.world
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      I have a similar one but I did it this way:

      
      function ins {
        PACKAGE="${1}"
        exists() {
          command -v "$1" >/dev/null 2>&1
        }
      
        if exists dnf; then #Fedora
          sudo dnf update && sudo dnf install -y $PACKAGE
        elif exists apt; then #Debian
          sudo apt update && sudo apt install -y $PACKAGE
        elif exists apk; then #Alpine
          apk -U upgrade && apk add $PACKAGE
        elif exists emerge; then #Gentoo
          sudo emerge $PACKAGE
        elif exists zypper; then #Suse
          sudo zypper ref && sudo zypper install $PACKAGE
        elif exists pacman; then #Arch
          pacman -S $PACKAGE
        elif exists brew; then #MacOS
          brew install $PACKAGE
        else
          echo "Error can't install package $PACKAGE. No package manager is detected."
          exit 1;
        fi
      }