Last active
February 7, 2026 16:51
-
-
Save daothinh/8b5e9b1bb9853c98d8b8c129a7f4dd36 to your computer and use it in GitHub Desktop.
Auto Setup Zsh Hacking Style (Kali Linux) 1-Click
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 | |
| # ============================================================================== | |
| # Script: setup_omz_hacking.sh | |
| # Description: One-click setup for Oh My Zsh with 'half-life' theme | |
| # and Kali-style plugins (autosuggestions, syntax-highlighting). | |
| # Author: daothinh | |
| # ============================================================================== | |
| set -e | |
| # Colors | |
| GREEN='\033[0;32m' | |
| BLUE='\033[0;34m' | |
| YELLOW='\033[1;33m' | |
| RED='\033[0;31m' | |
| NC='\033[0m' | |
| log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } | |
| log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; } | |
| log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } | |
| log_error() { echo -e "${RED}[ERROR]${NC} $1"; } | |
| # 1. Detect OS and Install Dependencies | |
| install_deps() { | |
| log_info "Checking dependencies..." | |
| local cmd_install="" | |
| if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
| if command -v apt-get &>/dev/null; then | |
| cmd_install="sudo apt-get update && sudo apt-get install -y" | |
| elif command -v dnf &>/dev/null; then | |
| cmd_install="sudo dnf install -y" | |
| elif command -v yum &>/dev/null; then | |
| cmd_install="sudo yum install -y" | |
| elif command -v pacman &>/dev/null; then | |
| cmd_install="sudo pacman -S --noconfirm" | |
| fi | |
| elif [[ "$OSTYPE" == "darwin"* ]]; then | |
| if command -v brew &>/dev/null; then | |
| cmd_install="brew install" | |
| else | |
| log_error "Homebrew not found on macOS. Please install Homebrew first." | |
| exit 1 | |
| fi | |
| fi | |
| if [ -z "$cmd_install" ]; then | |
| log_warn "Could not detect package manager. Assuming dependencies are installed or manual installation required." | |
| else | |
| for pkg in zsh git curl; do | |
| if ! command -v "$pkg" &>/dev/null; then | |
| log_info "Installing $pkg..." | |
| eval "$cmd_install $pkg" | |
| fi | |
| done | |
| fi | |
| log_success "Dependencies checked." | |
| } | |
| # 2. Install Oh My Zsh | |
| install_omz() { | |
| if [ ! -d "$HOME/.oh-my-zsh" ]; then | |
| log_info "Installing Oh My Zsh..." | |
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended | |
| log_success "Oh My Zsh installed." | |
| else | |
| log_info "Oh My Zsh folder already exists. Skipping..." | |
| fi | |
| } | |
| # 3. Install Plugins | |
| install_plugins() { | |
| local ZSH_CUSTOM=${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom} | |
| local PLUGINS=( | |
| "zsh-autosuggestions:https://github.com/zsh-users/zsh-autosuggestions" | |
| "zsh-syntax-highlighting:https://github.com/zsh-users/zsh-syntax-highlighting.git" | |
| ) | |
| for entry in "${PLUGINS[@]}"; do | |
| IFS=":" read -r name url <<< "$entry" | |
| if [ ! -d "$ZSH_CUSTOM/plugins/$name" ]; then | |
| log_info "Cloning plugin $name..." | |
| git clone "$url" "$ZSH_CUSTOM/plugins/$name" | |
| else | |
| log_info "Plugin $name already exists." | |
| fi | |
| done | |
| } | |
| # 4. Configure .zshrc | |
| configure_zshrc() { | |
| local ZSHRC="$HOME/.zshrc" | |
| log_info "Configuring .zshrc..." | |
| # Backup | |
| if [ -f "$ZSHRC" ]; then | |
| cp "$ZSHRC" "$ZSHRC.backup.$(date +%s)" | |
| else | |
| cp "$HOME/.oh-my-zsh/templates/zshrc.zsh-template" "$ZSHRC" | |
| fi | |
| # Determine sed command based on OS | |
| local sed_cmd="sed -i" | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| sed_cmd="sed -i ''" | |
| fi | |
| # 1. Update Theme | |
| if grep -q "^ZSH_THEME=" "$ZSHRC"; then | |
| $sed_cmd 's/^ZSH_THEME=".*"/ZSH_THEME="half-life"/' "$ZSHRC" | |
| else | |
| if grep -q "^# ZSH_THEME=" "$ZSHRC"; then | |
| $sed_cmd 's/^# ZSH_THEME=".*"/ZSH_THEME="half-life"/' "$ZSHRC" | |
| else | |
| echo 'ZSH_THEME="half-life"' >> "$ZSHRC" | |
| fi | |
| fi | |
| # 2. Update Plugins | |
| local new_plugins="plugins=(git zsh-autosuggestions zsh-syntax-highlighting)" | |
| if grep -q "^plugins=(" "$ZSHRC"; then | |
| $sed_cmd "s/^plugins=(.*)/$new_plugins/" "$ZSHRC" | |
| else | |
| echo "$new_plugins" >> "$ZSHRC" | |
| fi | |
| log_success "Configuration updated." | |
| } | |
| # 5. Set Default Shell | |
| set_default_shell() { | |
| local zsh_path | |
| zsh_path=$(command -v zsh) | |
| if [ "$SHELL" != "$zsh_path" ]; then | |
| log_info "Changing default shell to zsh..." | |
| if command -v chsh &>/dev/null; then | |
| log_warn "Please manually run: chsh -s $(which zsh)" | |
| else | |
| log_warn "chsh command not found. You may need to change shell manually." | |
| fi | |
| else | |
| log_info "Default shell is already zsh." | |
| fi | |
| } | |
| main() { | |
| install_deps | |
| install_omz | |
| install_plugins | |
| configure_zshrc | |
| set_default_shell | |
| log_success "\nSetup Complete!" | |
| log_info "To apply changes, run: source ~/.zshrc OR exec zsh" | |
| } | |
| main |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
π Zsh Hacking Style Auto Setup
Script automates the installation of Zsh + Oh My Zsh in Kali Linux Style (Autosuggestions + Syntax Highlighting) with a single command.
β¨ Features
zsh-autosuggestions: Intelligent command suggestions (like Fish/AI).zsh-syntax-highlighting: Highlights valid/invalid commands instantly.π¦ How to Install (1-Line Command)
Run this in your terminal:
bash -c "$(curl -fsSL https://gist.githubusercontent.com/daothinh/8b5e9b1bb9853c98d8b8c129a7f4dd36/raw/install_zsh_hacking.sh)"