Created
September 21, 2025 02:13
-
-
Save coderkhalide/5406bd88a8a877090fa629aaf790e482 to your computer and use it in GitHub Desktop.
Oh My Gosh Script
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
| # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. | |
| # Initialization code that may require console input (password prompts, [y/n] | |
| # confirmations, etc.) must go above this block; everything else may go below. | |
| if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | |
| source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | |
| fi | |
| # ------- | |
| # Exports | |
| # ------- | |
| export PATH=$PATH:/Users/khalid/Library/Android/sdk/emulator | |
| export PATH=$PATH:/Users/khalid/Library/Android/sdk/platform-tools | |
| export ZSH="$HOME/.oh-my-zsh" | |
| export EDITOR='code' | |
| export BROWSER='open' | |
| # History settings | |
| export HISTSIZE=10000 | |
| export SAVEHIST=10000 | |
| export HISTFILE=~/.zsh_history | |
| setopt HIST_IGNORE_DUPS | |
| setopt HIST_IGNORE_ALL_DUPS | |
| setopt SHARE_HISTORY | |
| setopt APPEND_HISTORY | |
| setopt INC_APPEND_HISTORY | |
| # ------- | |
| # Oh My Zsh Configuration | |
| # ------- | |
| ZSH_THEME="powerlevel10k/powerlevel10k" | |
| CASE_SENSITIVE="true" | |
| ENABLE_CORRECTION="true" | |
| COMPLETION_WAITING_DOTS="true" | |
| DISABLE_UPDATE_PROMPT="true" | |
| # Enhanced plugins for productivity | |
| plugins=( | |
| git | |
| z | |
| zsh-autosuggestions | |
| zsh-syntax-highlighting | |
| brew | |
| macos | |
| web-search | |
| copypath | |
| copyfile | |
| dirhistory | |
| extract | |
| jsontools | |
| node | |
| npm | |
| yarn | |
| docker | |
| kubectl | |
| ) | |
| source $ZSH/oh-my-zsh.sh | |
| # ------- | |
| # General Aliases | |
| # ------- | |
| alias l="ls" | |
| alias ll="ls -al" | |
| alias la="ls -la" | |
| alias lt="ls -ltr" | |
| alias o="open ." | |
| alias c="clear" | |
| alias h="history" | |
| alias ..="cd .." | |
| alias ...="cd ../.." | |
| alias ....="cd ../../.." | |
| alias ~="cd ~" | |
| alias -- -="cd -" | |
| # System shortcuts | |
| alias reload="source ~/.zshrc" | |
| alias zshconfig="$EDITOR ~/.zshrc" | |
| alias ohmyzsh="$EDITOR ~/.oh-my-zsh" | |
| alias hosts="sudo $EDITOR /etc/hosts" | |
| # ---------------------- | |
| # Enhanced Git Aliases | |
| # ---------------------- | |
| alias gaa='git add .' | |
| alias gcm='git commit -m' | |
| alias gca='git commit -am' | |
| alias gpsh='git push' | |
| alias gpll='git pull' | |
| alias gss='git status -s' | |
| alias gs='echo ""; echo "*********************************************"; echo -e " DO NOT FORGET TO PULL BEFORE COMMITTING"; echo "*********************************************"; echo ""; git status' | |
| alias gb='git branch' | |
| alias gco='git checkout' | |
| alias gcb='git checkout -b' | |
| alias gd='git diff' | |
| alias gl='git log --oneline -10' | |
| alias gundo='git reset --soft HEAD~1' | |
| alias gstash='git stash' | |
| alias gpop='git stash pop' | |
| # ---------------------- | |
| # Development Aliases | |
| # ---------------------- | |
| alias py='python3' | |
| alias pip='pip3' | |
| alias serve='python3 -m http.server 8000' | |
| # Network info | |
| alias publicip='curl ipinfo.io/ip' | |
| alias localip='ipconfig getifaddr en0' | |
| # Node.js shortcuts | |
| alias ni='npm install' | |
| alias ns='npm start' | |
| alias nt='npm test' | |
| alias nr='npm run' | |
| alias yi='yarn install' | |
| alias ys='yarn start' | |
| alias yt='yarn test' | |
| # Docker shortcuts | |
| alias d='docker' | |
| alias dc='docker-compose' | |
| alias dps='docker ps' | |
| alias di='docker images' | |
| # ---------------------- | |
| # Cool Terminal Features | |
| # ---------------------- | |
| # Better ls with colors and icons (if you have exa/eza installed) | |
| if command -v eza >/dev/null 2>&1; then | |
| alias ls='eza --icons' | |
| alias ll='eza -la --icons --git' | |
| alias lt='eza -la --icons --git --sort=modified' | |
| alias tree='eza --tree --icons' | |
| elif command -v exa >/dev/null 2>&1; then | |
| alias ls='exa --icons' | |
| alias ll='exa -la --icons --git' | |
| alias lt='exa -la --icons --git --sort=modified' | |
| alias tree='exa --tree --icons' | |
| fi | |
| # Better cat with syntax highlighting | |
| if command -v bat >/dev/null 2>&1; then | |
| alias cat='bat --style=numbers,changes' | |
| alias less='bat --paging=always' | |
| fi | |
| # Better diff | |
| if command -v delta >/dev/null 2>&1; then | |
| alias diff='delta' | |
| fi | |
| # JSON pretty printing | |
| alias json='python3 -m json.tool' | |
| # Process monitoring | |
| alias top='htop' | |
| alias psg='ps aux | grep -i' | |
| # Network monitoring | |
| alias ports='lsof -i -P | grep LISTEN' | |
| alias netstat='lsof -i' | |
| # Disk usage with ncdu (if installed) | |
| if command -v ncdu >/dev/null 2>&1; then | |
| alias du='ncdu --color dark -rr -x' | |
| fi | |
| # ---------------------- | |
| # Useful Functions | |
| # ---------------------- | |
| # Create directory and cd into it | |
| mkcd() { | |
| mkdir -p "$1" && cd "$1" | |
| } | |
| # Extract various archive formats | |
| extract() { | |
| if [ -f $1 ] ; then | |
| case $1 in | |
| *.tar.bz2) tar xjf $1 ;; | |
| *.tar.gz) tar xzf $1 ;; | |
| *.bz2) bunzip2 $1 ;; | |
| *.rar) unrar e $1 ;; | |
| *.gz) gunzip $1 ;; | |
| *.tar) tar xf $1 ;; | |
| *.tbz2) tar xjf $1 ;; | |
| *.tgz) tar xzf $1 ;; | |
| *.zip) unzip $1 ;; | |
| *.Z) uncompress $1 ;; | |
| *.7z) 7z x $1 ;; | |
| *) echo "'$1' cannot be extracted via extract()" ;; | |
| esac | |
| else | |
| echo "'$1' is not a valid file" | |
| fi | |
| } | |
| # Find files and directories | |
| ff() { find . -name "*$1*" 2>/dev/null } | |
| fd() { find . -type d -name "*$1*" 2>/dev/null } | |
| # Quick backup | |
| backup() { | |
| cp "$1" "$1.backup.$(date +%Y%m%d_%H%M%S)" | |
| } | |
| # Weather function | |
| weather() { | |
| curl -s "wttr.in/$1?format=3" | |
| } | |
| # Show file size in human readable format | |
| sizeof() { | |
| du -sh "$1" | |
| } | |
| # Kill process by name | |
| killp() { | |
| ps aux | grep -i "$1" | grep -v grep | awk '{print $2}' | xargs kill -9 | |
| } | |
| # Show comprehensive IP information | |
| myIp() { | |
| echo "π Network Information:" | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ" | |
| ifconfig lo0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "lo0 : " $2}' | |
| ifconfig en0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en0 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}' | |
| ifconfig en0 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en0 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}' | |
| ifconfig en1 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en1 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}' | |
| ifconfig en1 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en1 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}' | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ" | |
| echo -n "Public IP : " | |
| curl -s ipinfo.io/ip 2>/dev/null || echo "Unable to fetch" | |
| echo "" | |
| } | |
| # Display available custom functions and aliases | |
| help() { | |
| echo "π Custom Terminal Functions & Aliases" | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ" | |
| echo "" | |
| echo "π NAVIGATION:" | |
| echo " mkcd <dir> - Create directory and cd into it" | |
| echo " .. - Go up one directory" | |
| echo " ... - Go up two directories" | |
| echo " .... - Go up three directories" | |
| echo " - - Go to previous directory" | |
| echo " ~ - Go to home directory" | |
| echo "" | |
| echo "π SEARCH & FIND:" | |
| echo " ff <n> - Find files by name" | |
| echo " fd <n> - Find directories by name" | |
| echo " sizeof <path> - Show file/directory size" | |
| echo " fif - Interactive file finder with preview" | |
| echo "" | |
| echo "π FILE OPERATIONS:" | |
| echo " backup <file> - Create timestamped backup" | |
| echo " extract <file> - Extract any archive format" | |
| echo " copypath - Copy current path to clipboard" | |
| echo " copyfile <f> - Copy file contents to clipboard" | |
| echo "" | |
| echo "π NETWORK & SYSTEM:" | |
| echo " myip - Show all network interfaces" | |
| echo " publicip - Show public IP only" | |
| echo " localip - Show local IP only" | |
| echo " weather <city> - Get weather info" | |
| echo " killp <n> - Kill process by name" | |
| echo " sysinfo - System information dashboard" | |
| echo "" | |
| echo "β‘ GIT SHORTCUTS:" | |
| echo " gaa - git add ." | |
| echo " gcm '<msg>' - git commit -m" | |
| echo " gca '<msg>' - git add . && git commit -m" | |
| echo " gpsh - git push" | |
| echo " gpll - git pull" | |
| echo " gss - git status -s" | |
| echo " gs - git status (with reminder)" | |
| echo " gb - git branch" | |
| echo " gco <branch> - git checkout" | |
| echo " gcb <branch> - git checkout -b (create new)" | |
| echo " gd - git diff" | |
| echo " gl - git log --oneline -10" | |
| echo " gundo - git reset --soft HEAD~1" | |
| echo " gstash - git stash" | |
| echo " gpop - git stash pop" | |
| echo " gbrr - Interactive branch switcher" | |
| echo "" | |
| echo "π§ DEVELOPMENT:" | |
| echo " serve - Start HTTP server (port 8000)" | |
| echo " ni/yi - npm/yarn install" | |
| echo " ns/ys - npm/yarn start" | |
| echo " nr <script> - npm run <script>" | |
| echo " py - python3" | |
| echo " d - docker" | |
| echo " dc - docker-compose" | |
| echo " dps - docker ps" | |
| echo "" | |
| echo "π PRODUCTIVITY:" | |
| echo " note <text> - Quick note taking" | |
| echo " note - View recent notes" | |
| echo " bookmark <n> - Bookmark current directory" | |
| echo " goto <n> - Jump to bookmarked directory" | |
| echo " genpass [len] - Generate secure password" | |
| echo " colors - Show color palette" | |
| echo " tip - Get productivity tip" | |
| echo "" | |
| echo "π WEB SEARCH (from terminal):" | |
| echo " google <query> - Search Google" | |
| echo " youtube <q> - Search YouTube" | |
| echo " github <q> - Search GitHub" | |
| echo "" | |
| echo "βοΈ SYSTEM:" | |
| echo " reload - Reload .zshrc" | |
| echo " zshconfig - Edit .zshrc" | |
| echo " c - clear screen" | |
| echo " h - history" | |
| echo " help - Show this help" | |
| echo " funcs - Quick function list" | |
| echo "" | |
| echo "π‘ TIP: Use Tab for autocompletion, Ctrl+R for history search" | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ" | |
| } | |
| # Quick function list (shorter version) | |
| funcs() { | |
| echo "π§ Available Functions:" | |
| echo "myip | help | mkcd | ff | fd | sizeof | backup | extract | weather | killp" | |
| echo "sysinfo | note | bookmark | goto | genpass | colors | tip | fif | gbrr" | |
| echo "" | |
| echo "Type 'help' for detailed usage information" | |
| } | |
| # ---------------------- | |
| # Advanced Functions | |
| # ---------------------- | |
| # Interactive file finder with preview | |
| fif() { | |
| if command -v fzf >/dev/null 2>&1; then | |
| find . -type f | fzf --preview 'head -100 {}' | |
| else | |
| echo "Install fzf first: brew install fzf" | |
| fi | |
| } | |
| # Interactive git branch switcher | |
| gbrr() { | |
| if command -v fzf >/dev/null 2>&1; then | |
| git branch | fzf | sed 's/\* //' | xargs git checkout | |
| else | |
| echo "Install fzf first: brew install fzf" | |
| fi | |
| } | |
| # Quick note taking | |
| note() { | |
| local note_file="$HOME/notes.txt" | |
| if [ $# -eq 0 ]; then | |
| # Show recent notes | |
| echo "π Recent notes:" | |
| tail -10 "$note_file" 2>/dev/null || echo "No notes yet!" | |
| else | |
| # Add new note with timestamp | |
| echo "[$(date '+%Y-%m-%d %H:%M')] $*" >> "$note_file" | |
| echo "β Note added!" | |
| fi | |
| } | |
| # System info dashboard | |
| sysinfo() { | |
| echo "π₯οΈ System Information Dashboard" | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ" | |
| echo "π Date: $(date)" | |
| echo "β±οΈ Uptime: $(uptime | awk '{print $3,$4}' | sed 's/,//')" | |
| echo "π» System: $(uname -srm)" | |
| echo "π User: $(whoami)" | |
| echo "π PWD: $(pwd)" | |
| echo "π IP: $(curl -s ipinfo.io/ip 2>/dev/null || echo "Offline")" | |
| echo "πΎ Disk: $(df -h / | tail -1 | awk '{print $4" free of "$2}')" | |
| echo "π§ Memory: $(vm_stat | grep "Pages free" | awk '{print int($3)*4096/1024/1024"MB free"}')" | |
| echo "π₯ CPU: $(sysctl -n machdep.cpu.brand_string)" | |
| echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ" | |
| } | |
| # Directory bookmark system | |
| bookmark() { | |
| local bookmark_file="$HOME/.bookmarks" | |
| if [ $# -eq 0 ]; then | |
| # List bookmarks | |
| echo "π Bookmarks:" | |
| if [ -f "$bookmark_file" ]; then | |
| cat "$bookmark_file" | nl | |
| else | |
| echo "No bookmarks yet!" | |
| fi | |
| else | |
| # Add bookmark | |
| echo "$(pwd)|$1" >> "$bookmark_file" | |
| echo "π Bookmarked '$(pwd)' as '$1'" | |
| fi | |
| } | |
| goto() { | |
| local bookmark_file="$HOME/.bookmarks" | |
| if [ $# -eq 0 ]; then | |
| echo "Usage: goto <bookmark_name>" | |
| bookmark | |
| return 1 | |
| fi | |
| if [ -f "$bookmark_file" ]; then | |
| local path=$(grep "|$1$" "$bookmark_file" | cut -d'|' -f1) | |
| if [ -n "$path" ]; then | |
| cd "$path" | |
| echo "π Jumped to: $(pwd)" | |
| else | |
| echo "β Bookmark '$1' not found" | |
| fi | |
| else | |
| echo "β No bookmarks file found" | |
| fi | |
| } | |
| # Password generator | |
| genpass() { | |
| local length=${1:-16} | |
| LC_ALL=C tr -dc 'A-Za-z0-9!@#$%^&*()_+=' < /dev/urandom | head -c $length | |
| echo | |
| } | |
| # QR Code generator for text | |
| qr() { | |
| if [ $# -eq 0 ]; then | |
| echo "Usage: qr 'text to encode'" | |
| return 1 | |
| fi | |
| curl -s "https://qr-server.com/api/v1/create-qr-code/?size=200x200&data=$1" | |
| } | |
| # Color palette display | |
| colors() { | |
| for i in {0..255}; do | |
| printf "\e[38;5;${i}m%3d " "$i" | |
| if (( ($i + 1) % 16 == 0 )); then | |
| printf "\e[0m\n" | |
| fi | |
| done | |
| printf "\e[0m\n" | |
| } | |
| # Speedtest (using curl) | |
| speedtest() { | |
| echo "π Running speed test..." | |
| echo "Download test:" | |
| curl -o /dev/null -s -w "Speed: %{speed_download} bytes/sec (%.2f KB/sec)\n" http://speedtest.wdc01.softlayer.com/downloads/test10.zip -m 10 2>/dev/null | awk '{printf "Speed: %.2f MB/sec\n", $2/1024/1024}' | |
| } | |
| # Random quote/tip of the day | |
| tip() { | |
| local tips=( | |
| "π‘ Use 'Ctrl+R' to search command history interactively" | |
| "π Use 'ff <n>' to find files quickly" | |
| "π Use 'mkcd <dir>' to create and enter directory in one command" | |
| "π Use 'weather <city>' to get weather info" | |
| "π Use 'note <text>' to quickly save notes" | |
| "π Use 'bookmark <n>' to save current directory" | |
| "π― Use 'goto <n>' to jump to bookmarked directory" | |
| "π Use 'genpass' to generate secure passwords" | |
| "π Use 'sysinfo' to see system dashboard" | |
| "π¨ Use 'colors' to see all terminal colors" | |
| "β‘ Use 'fif' to interactively find and preview files" | |
| "π³ Use 'gbrr' to interactively switch git branches" | |
| "π± Use 'qr <text>' to generate QR codes" | |
| ) | |
| echo "${tips[$RANDOM % ${#tips[@]}]}" | |
| } | |
| # ---------------------- | |
| # Conditional Loads | |
| # ---------------------- | |
| # Load nvm if it exists | |
| if [[ -d "$HOME/.nvm" ]]; then | |
| export NVM_DIR="$HOME/.nvm" | |
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
| [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" | |
| fi | |
| # Load rbenv if it exists | |
| if command -v rbenv >/dev/null 2>&1; then | |
| eval "$(rbenv init -)" | |
| fi | |
| # Load pyenv if it exists | |
| if command -v pyenv >/dev/null 2>&1; then | |
| export PYENV_ROOT="$HOME/.pyenv" | |
| export PATH="$PYENV_ROOT/bin:$PATH" | |
| eval "$(pyenv init -)" | |
| fi | |
| # ---------------------- | |
| # Custom Key Bindings | |
| # ---------------------- | |
| # Use ctrl+r for history search (enhanced with fzf if available) | |
| if command -v fzf >/dev/null 2>&1; then | |
| bindkey '^R' fzf-history-widget | |
| fi | |
| # ---------------------- | |
| # Performance Optimizations | |
| # ---------------------- | |
| # Skip verification of insecure directories (if you trust your environment) | |
| ZSH_DISABLE_COMPFIX=true | |
| # Lazy load heavy commands | |
| lazy_load() { | |
| local cmd="$1" | |
| local init_cmd="$2" | |
| eval "$cmd() { unset -f $cmd; $init_cmd; $cmd \$@ }" | |
| } | |
| # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. | |
| [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment