# .zsh_aliases

alias mpset="make -C ~/Config/Dot-Zsh"

# Aliases
alias c="clear"

alias vi="nvim"
alias vim="nvim"

alias ls="eza --icons"
alias la="eza --icons -a"
alias ll="eza --icons -la"

alias grep="grep --color=auto"

alias src="source ~/.zshrc && echo '🔄 Reloaded .zshrc'"

alias cat="bat"
alias fd="fd"

alias tree="eza --icons -T --git-ignore"

# Navigation
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias ~="cd ~"
alias back="cd -"

# File Management
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
alias mkcd='foo() { mkdir -p "$1"; cd "$1"; }; foo'

# Storage
alias dfh="df -h"                                                   # Disk Free in Human Readable format
alias duh="du -h --max-depth=1"                                     # Disk Usage in Human Readable format

# System
alias top="btop"
alias cpu="lscpu"

# Network
alias ip="ip -c"                                                    # IP command with colorized output
alias ports="ss -tulanp"                                            # List all listening ports
alias myip="curl ifconfig.me"                                       # Get public IP address
alias pingg="ping google.com"                                       # Network Testing

# WSL Specific
if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
    # 1. Windows Explorer
    alias winExp="/mnt/c/Windows/explorer.exe"
    alias open="/mnt/c/Windows/explorer.exe" # Mac-style 'open' command

    # 2. VS Code (Dynamic Alias)
    if [ -f "/mnt/c/Windows/System32/cmd.exe" ]; then
        _WIN_USER=$(/mnt/c/Windows/System32/cmd.exe /c 'echo %USERNAME%' 2>/dev/null | tr -d '\r')
        
        # Only proceed if we actually got a username back
        if [ -n "$_WIN_USER" ]; then
            USER_CODE="/mnt/c/Users/$_WIN_USER/AppData/Local/Programs/Microsoft VS Code/bin/code"
            SYS_CODE="/mnt/c/Program Files/Microsoft VS Code/bin/code"

            if [ -f "$USER_CODE" ]; then
                # We use single quotes for the alias definition to handle the spaces safely
                alias code="'$USER_CODE'"
            elif [ -f "$SYS_CODE" ]; then
                alias code="'$SYS_CODE'"
            fi
        fi
    fi
fi

alias local-stt="python ~/Application/STT/stt.py"

# Vault
alias vl="vault login -method=userpass username=mangopig"
alias vs="vault status"
alias vkv="vault kv get"
alias vkvl="vault kv list"

# Proxy
proxy_on() {
    export ALL_PROXY=socks5h://192.168.1.26:1080
    export HTTP_PROXY=socks5h://192.168.1.26:1080
    export HTTPS_PROXY=socks5h://192.168.1.26:1080
    echo "Proxy ON (Mullvad NL)"
}
proxy_off() {
    unset ALL_PROXY HTTP_PROXY HTTPS_PROXY
    echo "Proxy OFF (direct)"
}