Skip to content

Instantly share code, notes, and snippets.

@dnegi-dev
Last active March 8, 2023 14:45
Show Gist options
  • Save dnegi-dev/af4bd1abc162413b3236f4cd9c2de4f1 to your computer and use it in GitHub Desktop.
Save dnegi-dev/af4bd1abc162413b3236f4cd9c2de4f1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
################################################################################
# This script checks for the Linux operating system and uses the appropriate
# package manager to install the zsh shell, tmux, and byobu. To run this script
# directly from GitHub Gist, use the following command:
#
# bash <(curl -s https://gist.githubusercontent.com/dnegi-dev/af4bd1abc162413b3236f4cd9c2de4f1/raw/4e9c8ecd3fc82fe97e9792850844b3ab588c53a0/install_zsh_and_byobu.sh)
#
# The script will automatically detect the package manager used by the system
# and install zsh, tmux, and byobu using that package manager. Supported package
# managers are:
# - apt-get (Ubuntu, Debian, and other Debian-based systems)
# - dnf (Fedora, Red Hat, CentOS)
# - yum (older Red Hat, CentOS)
# - zypper (OpenSUSE)
# - emerge (Gentoo)
# - pacman (Arch Linux)
################################################################################
# Define programs to install
PROGRAMS="zsh tmux byobu"
# Inform the user what the script is doing
echo "Installing $PROGRAMS..."
# Check if the current operating system is Linux
if [[ "$(uname)" != "Linux" ]]; then
echo "This script only works on Linux."
exit 1
fi
# Check if the system uses apt-get as its package manager
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y $PROGRAMS
# Check if the system uses dnf as its package manager (Fedora, Red Hat, CentOS)
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install $PROGRAMS
# Check if the system uses yum as its package manager (older Red Hat, CentOS)
elif command -v yum >/dev/null 2>&1; then
sudo yum install $PROGRAMS
# Check if the system uses zypper as its package manager (OpenSUSE)
elif command -v zypper >/dev/null 2>&1; then
sudo zypper install $PROGRAMS
# Check if the system uses emerge as its package manager (Gentoo)
elif command -v emerge >/dev/null 2>&1; then
sudo emerge -av $PROGRAMS
# Check if the system uses pacman as its package manager (Arch Linux)
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -Syu $PROGRAMS
# If the package manager is not recognized, display an error message
else
echo "Unable to determine the package manager for this system."
exit 1
fi
#Install Oh-My-Zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
# Inform the user that the script is finished
echo "Installation complete. You can now run 'zsh', 'tmux', or 'byobu' to start using these."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment