Skip to content

Instantly share code, notes, and snippets.

@ayoubzulfiqar
Created January 31, 2026 12:56
Show Gist options
  • Select an option

  • Save ayoubzulfiqar/8419d5182eb914c17a0b74848e0037bb to your computer and use it in GitHub Desktop.

Select an option

Save ayoubzulfiqar/8419d5182eb914c17a0b74848e0037bb to your computer and use it in GitHub Desktop.
Zsh Profile Configuration
#!/bin/bash
echo "πŸš€ INITIATING SENSEI MASTER ENVIRONMENT SYNC..."
# --- 1. Helper: Install Packages ---
install_pkg() {
if ! command -v $1 &> /dev/null; then
echo "πŸ“¦ Installing $1..."
if command -v apt &> /dev/null; then
sudo apt update && sudo apt install -y $1
elif command -v dnf &> /dev/null; then
sudo dnf install -y $1
fi
fi
}
# --- 2. Core Dependencies ---
install_pkg "curl"
install_pkg "git"
install_pkg "eza"
install_pkg "unzip"
install_pkg "lsof"
install_pkg "p7zip-full"
install_pkg "fzf" # Fuzzy searching
install_pkg "zoxide" # Smart directory jumping
install_pkg "bat" # Syntax highlighting for cat
install_pkg "nvtop" # GPU monitoring
install_pkg "thefuck" # Auto-correction
# --- 3. Oh My Zsh Installation ---
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "πŸ› οΈ Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
# --- 4. Plugins ---
ZSH_CUSTOM="$HOME/.oh-my-zsh/custom"
mkdir -p "$ZSH_CUSTOM/plugins"
[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ] && git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ] && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
# --- 5. Oh My Posh Installation ---
mkdir -p ~/.local/bin
if ! command -v oh-my-posh &> /dev/null; then
curl -sSLf https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -o ~/.local/bin/oh-my-posh
chmod +x ~/.local/bin/oh-my-posh
fi
mkdir -p ~/.config/oh-my-posh
# --- 6. The Master .zshrc Generation ---
echo "πŸ“ Writing Ultimate configuration to ~/.zshrc..."
cat << 'CONFIG' > ~/.zshrc
# ====================================================================
# ZSH CONFIGURATION (SENSEI MASTER EDITION)
# ====================================================================
# --- Path & Environment ---
export PATH="$HOME/.local/bin:$PATH"
export ZSH="$HOME/.oh-my-zsh"
# --- Oh My Zsh Core ---
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
[ -f "$ZSH/oh-my-zsh.sh" ] && source "$ZSH/oh-my-zsh.sh"
# --- Oh My Posh (Prompt) ---
if command -v oh-my-posh &> /dev/null; then
if [ -f ~/.config/oh-my-posh/zash.omp.json ]; then
eval "$(oh-my-posh init zsh --config ~/.config/oh-my-posh/zash.omp.json)"
else
eval "$(oh-my-posh init zsh --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/jandedobbeleer.omp.json)"
fi
fi
# --- Tool Initializations ---
eval "$(zoxide init zsh)"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
command -v thefuck &> /dev/null && eval $(thefuck --alias)
# --- Aliases & Overrides ---
alias pro="zed ~/.zshrc"
alias rl="source ~/.zshrc && echo '⚑ Zsh profile reloaded!'"
alias c="clear"
alias pn="pnpm"
alias ll="eza -lah --icons --group-directories-first"
alias ls="eza --icons --group-directories-first"
alias gpu="nvtop"
alias myip="echo '🌍 Public IP: \$(curl -s http://ipinfo.io/ip)'"
alias cnc="npm cache clean --force"
if command -v batcat &> /dev/null; then
alias cat="batcat --paging=never"
elif command -v bat &> /dev/null; then
alias cat="bat --paging=never"
fi
# --- Safety & Navigation ---
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
# --- Port Management Suite ---
portkill() {
if [ $# -eq 0 ]; then echo "❌ Error: Provide a port."; return 1; fi
for port in "$@"; do
local pid=$(sudo lsof -t -i:"$port" -sTCP:LISTEN)
if [ -z "$pid" ]; then echo "ℹ️ Port $port is free."; else
local proc=$(ps -p "$pid" -o comm= 2>/dev/null)
echo "πŸ”₯ Killing $proc (Port $port)..."
echo "$pid" | xargs sudo kill -9 && echo "βœ… Port $port cleared."
fi
done
}
portlist() {
echo "πŸ“Š Active Listening Ports:"
printf "\033[1;34m%-15s %-7s %-10s %-7s %-s\033[0m\n" "COMMAND" "PID" "USER" "PORT" "ADDRESS"
sudo lsof -i -P -n | grep LISTEN | awk '{
split($9, a, ":");
port=a[length(a)];
printf "%-15s %-7s %-10s %-7s %-s\n", $1, $2, $3, port, $9
}' | sort -n -k4
}
alias watchports="watch -n 2 'sudo lsof -i -P -n | grep LISTEN'"
# --- Automation Functions ---
extract() {
if [ -f "$1" ]; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;; *.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;; *.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;; *.tar) tar xf "$1" ;;
*.zip) unzip "$1" ;; *.7z) 7z x "$1" ;;
*) echo "Unknown format: $1" ;;
esac
else echo "File not found: $1"; fi
}
google() {
local query=""
for arg in "$@"; do query+="${arg}+"; done
xdg-open "https://www.google.com/search?q=${query%?}" &> /dev/null
}
master-update() {
sudo apt update && sudo apt upgrade -y
omz update && oh-my-posh upgrade
echo "βœ… Master Update Complete!"
}
# --- Keyboard & UI ---
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=8"
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search
# --- Startup Dashboard ---
clear
echo -e "\033[1;34m"
echo " πŸš€ SENSEI WORKSTATION ACTIVE"
echo " ----------------------------"
echo -e "\033[0;32m Uptime: \033[0m $(uptime -p)"
echo -e "\033[0;32m Memory: \033[0m $(free -h | awk '/^Mem:/ {print $3 "/" $2}')"
echo -e "\033[0;32m Storage:\033[0m $(df -h / | awk '/\// {print $4}') free"
echo -e "\033[1;34m ----------------------------"
echo -e "\033[0m"
CONFIG
echo "βœ… SUCCESS! Your terminal has ascended."
echo "πŸ‘‰ Run 'source ~/.zshrc' to begin."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment