Skip to content

Instantly share code, notes, and snippets.

@cyfrost
Last active November 8, 2019 04:01

Revisions

  1. cyfrost renamed this gist Oct 14, 2019. 1 changed file with 5 additions and 7 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,18 @@
    #!/bin/bash

    # [TESTED ON FEDORA ONLY]
    #
    # This script will check if VSCodium is installed in your machine, if yes, then tries to update it to the latest version
    # else, installs whichever the latest version is.
    #
    # NOTE: There's already this repo (https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo) that provides
    # the codium package for RPM based distros but for some reason the download was extremely slow.
    # This script pulls the download from github directly (which is hopefully a tad bit faster).

    # Thanks to author of [this answer](https://stackoverflow.com/a/4024263/2631023)
    # Thanks to https://stackoverflow.com/a/4024263/2631023
    function verlte() {
    [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
    }

    # Thanks to author of [this answer](https://stackoverflow.com/a/4024263/2631023)
    # Thanks to https://stackoverflow.com/a/4024263/2631023
    function verlt() {
    [ "$1" = "$2" ] && return 1 || verlte $1 $2
    }
    @@ -26,13 +24,13 @@ function install_or_update_latest_codium() {
    LATEST_VERSION="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')" && \
    verlt "$INSTALLED_VERSION" "$LATEST_VERSION" && IS_UPDATE_AVAILABLE="yes" || IS_UPDATE_AVAILABLE="no"
    if [ "$IS_UPDATE_AVAILABLE" = "yes" ] || [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ]; then
    [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ] && MSG="Downloading and installing latest VSCodium (version: $LATEST_VERSION)..." || MSG="Updating VSCodium from $INSTALLED_VERSION to $LATEST_VERSION..."
    [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ] && MSG="Downloading and installing latest VSCodium v$LATEST_VERSION..." || MSG="Updating VSCodium from $INSTALLED_VERSION to $LATEST_VERSION..."
    printf "\n$MSG\n\n"
    RPM_DOWNLOAD="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep "https.*x86_64.rpm" | head -1 | cut -d '"' -f 4)"
    FILENAME="/tmp/vsodium.rpm"
    FILENAME="/tmp/vscodium.rpm"
    [ -f $FILENAME ] && rm -f $FILENAME
    wget -O $FILENAME $RPM_DOWNLOAD -q --show-progress
    sudo dnf install -y "$FILENAME" && rm -f $FILENAME || printf "\nError: failed to install VSCodium version $LATEST_VERSION.\n\n"
    sudo dnf install -y "$FILENAME" && rm -f $FILENAME; printf "\nFinished\n\n" || printf "\nError: failed to install VSCodium version $LATEST_VERSION.\n\n"
    else
    printf "\nVSCodium is already up-to-date (Installed: "$INSTALLED_VERSION", Latest: "$LATEST_VERSION").\n\n"
    fi
  2. cyfrost revised this gist Oct 11, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_or_update_vscodium.sh
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ function install_or_update_latest_codium() {
    LATEST_VERSION="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')" && \
    verlt "$INSTALLED_VERSION" "$LATEST_VERSION" && IS_UPDATE_AVAILABLE="yes" || IS_UPDATE_AVAILABLE="no"
    if [ "$IS_UPDATE_AVAILABLE" = "yes" ] || [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ]; then
    [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ] && MSG="Downloading and installing latest VSCodium (version: $LATEST_VERSION)..." || MSG "Updating VSCodium from $INSTALLED_VERSION to $LATEST_VERSION..."
    [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ] && MSG="Downloading and installing latest VSCodium (version: $LATEST_VERSION)..." || MSG="Updating VSCodium from $INSTALLED_VERSION to $LATEST_VERSION..."
    printf "\n$MSG\n\n"
    RPM_DOWNLOAD="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep "https.*x86_64.rpm" | head -1 | cut -d '"' -f 4)"
    FILENAME="/tmp/vsodium.rpm"
  3. cyfrost created this gist Oct 8, 2019.
    41 changes: 41 additions & 0 deletions install_or_update_vscodium.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #!/bin/bash

    # [TESTED ON FEDORA ONLY]
    #
    # This script will check if VSCodium is installed in your machine, if yes, then tries to update it to the latest version
    # else, installs whichever the latest version is.
    #
    # NOTE: There's already this repo (https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo) that provides
    # the codium package for RPM based distros but for some reason the download was extremely slow.
    # This script pulls the download from github directly (which is hopefully a tad bit faster).

    # Thanks to author of [this answer](https://stackoverflow.com/a/4024263/2631023)
    function verlte() {
    [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
    }

    # Thanks to author of [this answer](https://stackoverflow.com/a/4024263/2631023)
    function verlt() {
    [ "$1" = "$2" ] && return 1 || verlte $1 $2
    }

    # Checks if Codium is installed, if yes, tries to update it to latest version, else installs latest version.

    function install_or_update_latest_codium() {
    rpm -q codium | grep -q "not installed" && INSTALLED_VERSION="NOT_INSTALLED" || INSTALLED_VERSION="$(rpm -q --queryformat "%{VERSION}" codium)"
    LATEST_VERSION="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')" && \
    verlt "$INSTALLED_VERSION" "$LATEST_VERSION" && IS_UPDATE_AVAILABLE="yes" || IS_UPDATE_AVAILABLE="no"
    if [ "$IS_UPDATE_AVAILABLE" = "yes" ] || [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ]; then
    [ "$INSTALLED_VERSION" = "NOT_INSTALLED" ] && MSG="Downloading and installing latest VSCodium (version: $LATEST_VERSION)..." || MSG "Updating VSCodium from $INSTALLED_VERSION to $LATEST_VERSION..."
    printf "\n$MSG\n\n"
    RPM_DOWNLOAD="$(curl -sL https://api.github.com/repos/vscodium/vscodium/releases/latest | grep "https.*x86_64.rpm" | head -1 | cut -d '"' -f 4)"
    FILENAME="/tmp/vsodium.rpm"
    [ -f $FILENAME ] && rm -f $FILENAME
    wget -O $FILENAME $RPM_DOWNLOAD -q --show-progress
    sudo dnf install -y "$FILENAME" && rm -f $FILENAME || printf "\nError: failed to install VSCodium version $LATEST_VERSION.\n\n"
    else
    printf "\nVSCodium is already up-to-date (Installed: "$INSTALLED_VERSION", Latest: "$LATEST_VERSION").\n\n"
    fi
    }

    install_or_update_latest_codium