Created
February 21, 2026 13:26
-
-
Save n1sh1th/5248068402f5e058ad89c6da01153f30 to your computer and use it in GitHub Desktop.
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 | |
| TMUX_CONF="$HOME/.tmux.conf" | |
| CONF_URL="https://gist.githubusercontent.com/n1sh1th/e4acb4859483afb9c14da0598295f540/raw/5832c7f2caa69cef203dd7d02f60273484e806ed/tmux.conf" | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| RED='\033[0;31m' | |
| NC='\033[0m' # No Color | |
| log_info() { echo -e "${GREEN}[INFO]${NC} $1"; } | |
| log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } | |
| log_error() { echo -e "${RED}[ERROR]${NC} $1"; } | |
| if command -v tmux &>/dev/null; then | |
| log_info "tmux is already installed. ($(tmux -V))" | |
| else | |
| log_info "tmux not found. Installing..." | |
| sudo apt install tmux -y | |
| if command -v tmux &>/dev/null; then | |
| log_info "tmux installed successfully. ($(tmux -V))" | |
| else | |
| log_error "tmux installation failed. Exiting." | |
| exit 1 | |
| fi | |
| fi | |
| log_info "Downloading tmux configuration from remote..." | |
| # Check if curl or wget is available | |
| if command -v curl &>/dev/null; then | |
| CONF_CONTENT=$(curl -fsSL "$CONF_URL") | |
| elif command -v wget &>/dev/null; then | |
| CONF_CONTENT=$(wget -qO- "$CONF_URL") | |
| else | |
| log_error "Neither curl nor wget found. Cannot download config." | |
| exit 1 | |
| fi | |
| if [[ -z "$CONF_CONTENT" ]]; then | |
| log_error "Downloaded content is empty. Check the URL or your internet connection." | |
| exit 1 | |
| fi | |
| if [[ -f "$TMUX_CONF" ]]; then | |
| log_info "Found existing $TMUX_CONF — overwriting with new config..." | |
| echo "$CONF_CONTENT" > "$TMUX_CONF" | |
| else | |
| log_warn "$TMUX_CONF not found. Creating a new one with sudo..." | |
| TMPFILE=$(mktemp) | |
| echo "$CONF_CONTENT" > "$TMPFILE" | |
| sudo mv "$TMPFILE" "$TMUX_CONF" | |
| sudo chown "$USER":"$USER" "$TMUX_CONF" | |
| fi | |
| if [[ -f "$TMUX_CONF" ]]; then | |
| log_info "tmux config written successfully to $TMUX_CONF" | |
| log_info "Reload config in a running tmux session with: tmux source-file ~/.tmux.conf" | |
| else | |
| log_error "Failed to write tmux config." | |
| exit 1 | |
| fi | |
| log_info "Run chmod +x setup_tmux.sh && ./setup_tmux.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment