diff --git a/chaotic-aur/chaotic.sh b/chaotic-aur/chaotic.sh new file mode 100644 index 0000000..0132020 --- /dev/null +++ b/chaotic-aur/chaotic.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +# Color definitions for output +Green='\033[0;32m' +NC='\033[0m' # No Color + +# Function to check if a command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Function to check if Chaotic-AUR is already enabled in pacman.conf +check_chaotic_aur_enabled() { + if grep -q '^\[chaotic-aur\]' /etc/pacman.conf && grep -q 'Include = /etc/pacman.d/chaotic-mirrorlist' /etc/pacman.conf; then + return 0 + else + return 1 + fi +} + +# Function to check if mirrorlist exists +check_mirror_exists() { + if test -f "/etc/pacman.d/chaotic-mirrorlist"; then + return 0 + else + return 1 + fi +} + +# Function to setup mirrorlist +setup_mirrorlist() { + echo -e "${Green}Downloading Chaotic-AUR mirrorlist...${NC}" + wget -q -O chaotic-mirrorlist "https://raw.githubusercontent.com/chaotic-aur/pkgbuild-chaotic-mirrorlist/main/mirrorlist" + sudo mv chaotic-mirrorlist /etc/pacman.d/chaotic-mirrorlist + echo -e "${Green}Mirrorlist installed successfully.${NC}" +} + +# Function to append Chaotic-AUR to pacman.conf +append_pacman_conf() { + echo -e "${Green}Adding Chaotic-AUR to pacman.conf...${NC}" + echo "" | sudo tee -a /etc/pacman.conf > /dev/null + echo "#Chaotic-AUR" | sudo tee -a /etc/pacman.conf > /dev/null + echo "[chaotic-aur]" | sudo tee -a /etc/pacman.conf > /dev/null + echo "Include = /etc/pacman.d/chaotic-mirrorlist" | sudo tee -a /etc/pacman.conf > /dev/null + echo -e "${Green}Configuration added to pacman.conf.${NC}" +} + +# Function to initialize and sign keys +setup_keys() { + echo -e "${Green}Initializing and signing Chaotic-AUR keys...${NC}" + sudo pacman-key --recv-key 3056513887B78AEB --keyserver hkp://keyserver.ubuntu.com:80 + sudo pacman-key --lsign-key 3056513887B78AEB + echo -e "${Green}Keys signed successfully.${NC}" +} + +# Function to install keyring packages +install_keyring() { + echo -e "${Green}Installing Chaotic-AUR keyring and mirrorlist packages...${NC}" + sudo pacman -U --noconfirm \ + 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' \ + 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' + echo -e "${Green}Keyring packages installed.${NC}" +} + +# Main Execution +echo "Starting Chaotic-AUR Installation/Configuration..." + +# 1. Check if already installed and enabled +if check_chaotic_aur_enabled; then + echo -e "${Green}Chaotic-AUR is already installed and enabled in pacman.conf.${NC}" + echo "Checking for updates..." + sudo pacman -Syu chaotic-keyring + exit 0 +fi + +# 2. Check if mirrorlist exists, if not, download it +if ! check_mirror_exists; then + setup_mirrorlist +else + echo -e "${Green}Mirrorlist already exists.${NC}" +fi + +# 3. Ensure system is up-to-date before adding new repo +echo -e "${Green}Updating system packages...${NC}" +sudo pacman -Syu --noconfirm + +# 4. Setup Keys +setup_keys + +# 5. Install Keyring +install_keyring + +# 6. Append to pacman.conf +append_pacman_conf + +# 7. Refresh database +echo -e "${Green}Refreshing pacman database...${NC}" +sudo pacman -Sy + +echo -e "${Green}Chaotic-AUR installation and configuration complete.${NC}" +echo "You can now install packages from Chaotic-AUR using 'pacman -S ' or 'paru -S '." #!/bin/env bash diff --git a/zsh/tmux.conf b/zsh/tmux.conf new file mode 100644 index 0000000..1754e07 --- /dev/null +++ b/zsh/tmux.conf @@ -0,0 +1,139 @@ +# set prefix key to Ctrl-a +set -g prefix C-a + +# enable mouse mode +set -g mouse on + +# set default terminal to xterm-256color +set -g default-terminal "tmux-256color" + +# bind keys for pane navigation +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +# bind key for closing panes +bind x kill-pane +bind q confirm-before kill-session +# bind key for switching between windows +bind n next-window +bind p previous-window + +# cheatsheet & reload +bind ? display-popup -h 27 -w 46 -E "echo -e '╔══════════════════════════════════════════╗\n║  Tmux Cheatsheet ║\n╠══════════════════════════════════════════╣\n║ Press Ctrl+A (prefix) then: ║\n╠══════════════════════════════════════════╣\n║ PANES ║\n║ h/j/k/l Navigate pane ║\n║ | Split horizontally ║\n║ - Split vertically ║\n║ x Kill pane ║\n║ Ctrl+S Swap pane layout ║\n╠══════════════════════════════════════════╣\n║ WINDOWS ║\n║ n Next window ║\n║ p Previous window ║\n║ q Kill session ║\n║ c New window ║\n║ , Rename window ║\n╠══════════════════════════════════════════╣\n║ GENERAL ║\n║ r Reload config ║\n║ ? This cheatsheet ║\n╚══════════════════════════════════════════╝\nPress any key to close.' && read -n 1 -s" +bind r source-file ~/.config/tmux/tmux.conf + +# disable terminal flow control (so C-s doesn't freeze) +# set -g flow-control off # option not available in this tmux build + +# bind key for toggling between horizontal and vertical split +bind C-s swap-pane -s .-1 + +# split panes using | and - +bind | split-window -h +bind - split-window -v +unbind '"' +unbind % + +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-online-status' +set -g @plugin 'tmux-plugins/tmux-battery' +set -g @plugin 'tmux-plugins/tmux-cpu' +# GitHub Dark color palette +set -g @thm_bg "#0d1117" +set -g @thm_surface_0 "#161b22" +set -g @thm_overlay_0 "#30363d" +set -g @thm_red "#f85149" +set -g @thm_green "#3fb950" +set -g @thm_yellow "#d29922" +set -g @thm_blue "#58a6ff" +set -g @thm_mauve "#bc8cff" +set -g @thm_pink "#f778ba" +set -g @thm_peach "#f0883e" +set -g @thm_maroon "#ff7b72" +set -g @thm_rosewater "#c9d1d9" + +# Configure Online +set -g @online_icon "ok" +set -g @offline_icon "nok" + +# status left look and feel +set -g status-left-length 100 +set -g status-left "" +set -ga status-left "#{?client_prefix,#{#[bg=#{@thm_red},fg=#{@thm_bg},bold]  #S },#{#[bg=#{@thm_bg},fg=#{@thm_green}]  #S }}" +set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_overlay_0},none]│" +set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_maroon}]  #{pane_current_command} " +set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_overlay_0},none]│" +set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_blue}]  #{=/-32/...:#{s|$USER|~|:#{b:pane_current_path}}} " +set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_overlay_0},none]#{?window_zoomed_flag,│,}" +set -ga status-left "#[bg=#{@thm_bg},fg=#{@thm_yellow}]#{?window_zoomed_flag,  zoom ,}" + +# status right look and feel +set -g status-right-length 100 +set -g status-right "" +set -ga status-right "#{?#{e|>=:10,#{battery_percentage}},#{#[bg=#{@thm_red},fg=#{@thm_bg}]},#{#[bg=#{@thm_bg},fg=#{@thm_pink}]}} #{battery_icon} #{battery_percentage} " +set -ga status-right "#[bg=#{@thm_bg},fg=#{@thm_overlay_0}, none]│" +set -ga status-right "#[bg=#{@thm_bg}]#{?#{==:#{online_status},ok},#[fg=#{@thm_mauve}] 󰖩 on ,#[fg=#{@thm_red},bold]#[reverse] 󰖪 off }" +set -ga status-right "#[bg=#{@thm_bg},fg=#{@thm_overlay_0}, none]│" +set -ga status-right "#[bg=#{@thm_bg},fg=#{@thm_blue}] 󰭦 %a, %m-%d-%Y 󰅐 %I:%M %p " + +# start indexing at 1 (not 0) +set -g base-index 1 +setw -g pane-base-index 1 + +# misc quality-of-life +set -sg escape-time 0 +set -g status-interval 5 +set -g renumber-windows on +set -g focus-events on +setw -g aggressive-resize on +set -g set-clipboard on + +# bootstrap tpm +if "test ! -d ~/.config/tmux/plugins/tpm" \ + "run 'git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm && ~/.config/tmux/plugins/tpm/bin/install_plugins'" + +# auto-install a Nerd Font if missing (for icons) +run 'if ! fc-list :lang=en 2>/dev/null | grep -qi "nerd\\|jetbrainsmono\\|firacode\\|hack\\|iosevka\\|meslo"; then + mkdir -p ~/.local/share/fonts + if command -v curl >/dev/null 2>&1; then + curl -sL "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/JetBrainsMono.zip" -o /tmp/jetbrains-nerd.zip + elif command -v wget >/dev/null 2>&1; then + wget -q "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/JetBrainsMono.zip" -O /tmp/jetbrains-nerd.zip + fi + if [ -f /tmp/jetbrains-nerd.zip ]; then + unzip -qo /tmp/jetbrains-nerd.zip -d ~/.local/share/fonts/ 2>/dev/null + rm -f /tmp/jetbrains-nerd.zip + fc-cache -f ~/.local/share/fonts/ 2>/dev/null + fi +fi' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.config/tmux/plugins/tpm/tpm' + +# Configure Tmux +set -g status-position bottom +set -g status-style "bg=#{@thm_bg}" +set -g status-justify "absolute-centre" + +# pane border look and feel +setw -g pane-border-status bottom +setw -g pane-border-format "" +setw -g pane-active-border-style "bg=#{@thm_bg},fg=#{@thm_overlay_0}" +setw -g pane-border-style "bg=#{@thm_bg},fg=#{@thm_surface_0}" +setw -g pane-border-lines single + +# window look and feel +set -wg automatic-rename on +set -g automatic-rename-format "#{pane_current_command}" + +set -g window-status-format " #I#{?#{!=:#{window_name},Window},: #W,} " +set -g window-status-style "bg=#{@thm_bg},fg=#{@thm_rosewater}" +set -g window-status-last-style "bg=#{@thm_bg},fg=#{@thm_peach}" +set -g window-status-activity-style "bg=#{@thm_red},fg=#{@thm_bg}" +set -g window-status-bell-style "bg=#{@thm_red},fg=#{@thm_bg},bold" +set -gF window-status-separator "#[bg=#{@thm_bg},fg=#{@thm_overlay_0}]│" + +set -g window-status-current-format " #I#{?#{!=:#{window_name},Window},: #W,} " +set -g window-status-current-style "bg=#{@thm_peach},fg=#{@thm_bg},bold" diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100644 index 0000000..bdc59b0 --- /dev/null +++ b/zsh/zshrc @@ -0,0 +1,139 @@ +export ZSH_CONFIG=$HOME/.config/zsh +export OHMYZSH=$ZSH_CONFIG/oh-my-zsh +export OHMYZSH_CUSTOM=$OHMYZSH/custom + +export ZSHRC_URL="https://jeremy-web.space/scripts/zshrc" +export ZSHRC_BOOTSTRAP_URL="https://jeremy-web.space/scripts/zshrc-bootstrap.zsh" +export ZSHRC_BOOTSTRAP_VERSION="2" +export ZSHRC_BOOTSTRAP="$ZSH_CONFIG/.bootstrapped" + +[[ -d "$HOME/Scripts" ]] && path+=("$HOME/Scripts") +[[ -d "$HOME/.local/bin" ]] && path+=("$HOME/.local/bin") +[[ -d "$HOME/AppImages" ]] && path+=("$HOME/AppImages") + +update_zshrc(){ + local tmp=/tmp/.zshrc.$$ + curl -sSL --connect-timeout 5 "$ZSHRC_URL" -o "$tmp" 2>/dev/null || return + if ! cmp -s "$tmp" "$HOME/.zshrc" 2>/dev/null; then + echo "Updating zshrc..." + mv "$tmp" "$HOME/.zshrc" && echo "Updated. Reloading..." && exec zsh + fi + rm -f "$tmp" +} + +fix_btopbg(){ + sed -i 's/theme_background = true/theme_background = false/' ~/.config/btop/btop.conf +} + +# Bootstrap: download and run once per bootstrap version +if [[ ! -f "$ZSHRC_BOOTSTRAP" || "$(cat "$ZSHRC_BOOTSTRAP" 2>/dev/null)" != "$ZSHRC_BOOTSTRAP_VERSION" || "$BOOTSTRAP" == "true" ]]; then + tmp=/tmp/.zshrc_bootstrap.$$ + curl -sSL --connect-timeout 5 -o "$tmp" "$ZSHRC_BOOTSTRAP_URL" 2>/dev/null + if [[ -f "$tmp" ]]; then + zsh "$tmp" 2>/dev/null + echo "$ZSHRC_BOOTSTRAP_VERSION" > "$ZSHRC_BOOTSTRAP" + rm -f "$tmp" + fi +fi + +TMUXCONF="$HOME/.config/tmux" +BYOBUCONF="$HOME/.config/byobu" +TMUXREMOTE="https://jeremy-web.space/scripts/tmux.conf" +if [ ! -f "$TMUXCONF" ]; then + # Create a secure temporary file + TEMP_TMUXCONF=$(mktemp) + + # Download to temp file. + # The '&&' ensures the 'mv' only runs if curl succeeds (exit code 0). + if curl -sSL --connect-timeout 5 -o "$TEMP_TMUXCONF" "$TMUXREMOTE"; then + mkdir -p "$TMUXCONF" "$BYOBUCONF" + cp "$TEMP_TMUXCONF" "$TMUXCONF/tmux.conf" + mv "$TEMP_TMUXCONF" "$BYOBUCONF/.tmux.conf" + else + # Optional: Clean up temp file if download failed + rm -f "$TEMP_TMUXCONF" + echo "Error: Failed to download tmux config from $TMUXREMOTE" >&2 + fi +fi + +export HISTFILE="$ZSH_CONFIG/history" +export ZSH_COMPDUMP="$ZSH_CONFIG/zcompdump-${HOST}-${ZSH_VERSION}" +export HISTSIZE=10000 +export SAVEHIST=10000 + +setopt SHARE_HISTORY +setopt HIST_IGNORE_DUPS +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_REDUCE_BLANKS +setopt HIST_FCNTL_LOCK +setopt AUTO_CD +setopt AUTO_LIST +setopt INTERACTIVE_COMMENTS + +ZSH_THEME="" +ENABLE_CORRECTION="false" +HIST_STAMPS="mm/dd/yyyy" + +plugins=( + git + sudo + extract + eza + history + kitty + docker + docker-compose + archlinux + encode64 + universalarchive + zsh-autosuggestions + fast-syntax-highlighting + fzf + fzf-tab + systemd + vscode + rsync + starship +) + +zstyle ':omz:update' 'mode' auto +zstyle ':omz:plugins:eza' 'dirs-first' yes +zstyle ':omz:plugins:eza' 'git-status' yes +zstyle ':omz:plugins:eza' 'header' yes +zstyle ':omz:plugins:eza' 'show-group' yes +zstyle ':omz:plugins:eza' 'icons' yes +zstyle ':omz:plugins:eza' 'color-scale' all +zstyle ':omz:plugins:eza' 'color-scale-mode' fixed +zstyle ':omz:plugins:eza' 'size-prefix' si +zstyle ':omz:plugins:eza' 'hyperlink' yes + +zstyle ':completion:*' menu select +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" +zstyle ':completion:*' special-dirs true + +source $OHMYZSH/oh-my-zsh.sh + +alias c='clear' +alias q="exit" +alias nbstat=$'netbird status --json | jq -r \'.peers.details[]? | [(.hostname // .fqdn), .netbirdIp, .status] | @tsv\' | column -t -s $\'\\t\'' +alias open-ports="ss -tulpn | grep LISTEN" +alias yeet='yay -Rcs' + +# Auto-update: check every shell start, silently fail if server unreachable +if [[ -o interactive ]]; then + tmp=/tmp/.zshrc.$$ + curl -sSL --connect-timeout 3 "$ZSHRC_URL" -o "$tmp" 2>/dev/null + if [[ -f "$tmp" ]] && ! cmp -s "$tmp" "$HOME/.zshrc" 2>/dev/null; then + echo "Updating zshrc..." + mv "$tmp" "$HOME/.zshrc" && exec zsh + fi + rm -f "$tmp" +fi + +[[ -f $HOME/.zshrc.local ]] || touch $HOME/.zshrc.local +source $HOME/.zshrc.local + +if [[ $FFENABLED != "false" && ( -o interactive || $(tty) == *"pts"* ) ]] && command -v fastfetch >/dev/null; then + fastfetch --config examples/13 +fi diff --git a/zsh/zshrc-bootstrap.zsh b/zsh/zshrc-bootstrap.zsh new file mode 100644 index 0000000..8320067 --- /dev/null +++ b/zsh/zshrc-bootstrap.zsh @@ -0,0 +1,83 @@ +export ZSH_CONFIG=$HOME/.config/zsh +export OHMYZSH=$ZSH_CONFIG/oh-my-zsh +export OHMYZSH_CUSTOM=$OHMYZSH/custom + +touch ~/.hushlogin +mkdir -p "$HOME/.local/bin" +mkdir -p "$ZSH_CONFIG" +path+=("$HOME/.local/bin") + +for p in git starship fzf eza rsync lazydocker fastfetch tmux; do + command -v $p >/dev/null && continue + if command -v brew >/dev/null; then + echo "Installing $p using brew" && brew install $p && continue + fi + if command -v apt >/dev/null && apt-cache show $p >/dev/null 2>&1; then + echo "Installing $p using Apt" && sudo apt install $p -y && continue + fi + if command -v dnf >/dev/null && dnf list available -y $p >/dev/null 2>&1; then + echo "Installing $p using dnf" && sudo dnf install $p -y && continue + fi + if command -v pacman >/dev/null && pacman -Si $p >/dev/null 2>&1; then + echo "Installing $p using pacman" && sudo pacman -Sy --noconfirm $p && continue + fi + if command -v cargo >/dev/null; then + echo "Installing $p using cargo" && cargo install $p --locked && continue + fi +done + +if ! command -v starship >/dev/null; then + echo "Installing starship binary..." && \ + curl -sSL https://starship.rs/install.sh | sh -s -- -b ~/.local/bin -y >/dev/null 2>&1 +fi + +if ! command -v lazydocker >/dev/null; then + echo "Installing lazydocker binary..." && \ + curl -sSL https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | \ + DIR=$HOME/.local/bin bash >/dev/null 2>&1 +fi + +arch=$(uname -m) +case "$arch" in + x86_64) target_fast="linux-amd64" && target_eza="x86_64-unknown-linux-gnu" ;; + aarch64|arm64) target_fast="linux-aarch64" && target_eza="aarch64-unknown-linux-gnu" ;; + armv7l) target_fast="linux-armv7l" && target_eza="armv7-unknown-linux-gnueabihf" ;; +esac + +if [[ -n $target_fast && -n $target_eza ]]; then + if ! command -v fastfetch >/dev/null; then + curl -sSL -o /tmp/fastfetch.tar.gz "https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-${target_fast}.tar.gz" + tar -xzf /tmp/fastfetch.tar.gz -C /tmp + ffdir=$(find /tmp -maxdepth 1 -type d -name 'fastfetch*' | head -1) + cp "$ffdir/usr/bin/fastfetch" "$HOME/.local/bin/" + chmod +x "$HOME/.local/bin/fastfetch" + mkdir -p "$HOME/.local/share/fastfetch" + cp -r "$ffdir/usr/share/fastfetch/"* "$HOME/.local/share/fastfetch/" + rm -rf "$ffdir" /tmp/fastfetch.tar.gz + fi + + if ! command -v eza >/dev/null; then + curl -sSL -o /tmp/eza.tar.gz "https://github.com/eza-community/eza/releases/latest/download/eza_${target_eza}.tar.gz" + tar -xzf /tmp/eza.tar.gz -C "$HOME/.local/bin/" + chmod +x "$HOME/.local/bin/eza" + rm -f /tmp/eza.tar.gz + fi +fi + +mkdir -p "$HOME/.config/zsh" + +[ ! -d $OHMYZSH ] && git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git $OHMYZSH + +for plug in \ + "zsh-autosuggestions|https://github.com/zsh-users/zsh-autosuggestions" \ + "fast-syntax-highlighting|https://github.com/zdharma-continuum/fast-syntax-highlighting" \ + "fzf-tab|https://github.com/Aloxaf/fzf-tab" +do + name="${plug%%|*}" + url="${plug##*|}" + dir="$OHMYZSH_CUSTOM/plugins/$name" + [[ ! -d "$dir" ]] && git clone "$url" "$dir" 2>/dev/null +done + +# Cleanup +[[ -d $HOME/.config/oh-my-zsh ]] && rm -rf "$HOME/.config/oh-my-zsh"