Created
November 19, 2023 17:35
-
-
Save MohamedElashri/e29af0b06026cfac124f08121d07f5c0 to your computer and use it in GitHub Desktop.
bash script to automate installing helix editor on supported platforms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Function to check if a command exists | |
| command_exists() { | |
| command -v "$1" >/dev/null 2>&1 | |
| } | |
| # Function to install Helix on Ubuntu | |
| install_on_ubuntu() { | |
| echo "Installing Helix on Ubuntu..." | |
| sudo add-apt-repository ppa:maveonair/helix-editor | |
| sudo apt update | |
| sudo apt install helix | |
| } | |
| # Function to install Helix on MacOS | |
| install_on_mac() { | |
| echo "Installing Helix on MacOS..." | |
| brew install helix | |
| } | |
| # Function to install Helix on Windows | |
| install_on_windows() { | |
| echo "Checking for available Windows package managers..." | |
| if command_exists winget; then | |
| echo "Installing Helix using Winget..." | |
| winget install Helix.Helix | |
| elif command_exists scoop; then | |
| echo "Installing Helix using Scoop..." | |
| scoop install helix | |
| elif command_exists choco; then | |
| echo "Installing Helix using Chocolatey..." | |
| choco install helix | |
| elif command_exists pacman; then | |
| echo "Installing Helix using MSYS2..." | |
| pacman -S mingw-w64-ucrt-x86_64-helix | |
| else | |
| echo "No known package manager found for Helix installation on Windows." | |
| echo "Please install Winget, Scoop, Chocolatey, or MSYS2 and rerun this script." | |
| fi | |
| } | |
| # Function to install Helix on Fedora/RHEL | |
| install_on_fedora() { | |
| echo "Installing Helix on Fedora/RHEL..." | |
| sudo dnf copr enable varlad/helix | |
| sudo dnf install helix | |
| } | |
| # Function to install Helix on Arch Linux | |
| install_on_arch() { | |
| echo "Installing Helix on Arch Linux..." | |
| sudo pacman -S helix | |
| } | |
| # Detecting the platform and initiating installation | |
| detect_and_install() { | |
| OS="$(uname -s)" | |
| case "${OS}" in | |
| Linux*) | |
| # Detecting Linux distribution | |
| if [[ -f /etc/os-release ]]; then | |
| . /etc/os-release | |
| case $ID in | |
| ubuntu) | |
| install_on_ubuntu | |
| ;; | |
| fedora) | |
| install_on_fedora | |
| ;; | |
| arch) | |
| install_on_arch | |
| ;; | |
| *) | |
| echo "Unsupported Linux distribution" | |
| ;; | |
| esac | |
| else | |
| echo "Unable to detect Linux distribution." | |
| fi | |
| ;; | |
| Darwin*) | |
| install_on_mac | |
| ;; | |
| CYGWIN*|MINGW32*|MSYS*|MINGW*) | |
| install_on_windows | |
| ;; | |
| *) | |
| echo "Unsupported OS" | |
| ;; | |
| esac | |
| } | |
| # Main execution | |
| echo "Starting Helix editor installation script..." | |
| detect_and_install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment