Fixing WSL Alias

This commit is contained in:
MangoPig
2025-12-03 02:43:35 +00:00
parent dc33ab44c4
commit 9e7d121354
2 changed files with 18 additions and 18 deletions

View File

@@ -45,3 +45,21 @@ alias ip="ip -c" # IP command
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)
# This finds the username automatically so it works on any Windows machine
_WIN_USER=$(cmd.exe /c 'echo %USERNAME%' 2>/dev/null | tr -d '\r')
if [ -d "/mnt/c/Users/$_WIN_USER/AppData/Local/Programs/Microsoft VS Code/bin" ]; then
alias code="/mnt/c/Users/$_WIN_USER/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code"
elif [ -d "/mnt/c/Program Files/Microsoft VS Code/bin" ]; then
alias code="/mnt/c/Program\ Files/Microsoft\ VS\ Code/bin/code"
fi
fi