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 ports="ss -tulanp" # List all listening ports
alias myip="curl ifconfig.me" # Get public IP address alias myip="curl ifconfig.me" # Get public IP address
alias pingg="ping google.com" # Network Testing 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

18
.zshrc
View File

@ -54,21 +54,3 @@ eval "$(zoxide init --cmd cd zsh)"
# Add to PATH # Add to PATH
export PATH="$HOME/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH"
# ---------------------------------------------------------------------
# DYNAMIC VS CODE PATH (Run LAST)
# ---------------------------------------------------------------------
# Get Windows Username
WIN_USER=$(cmd.exe /c 'echo %USERNAME%' 2>/dev/null | tr -d '\r')
# Define potential paths (User Install vs System Install)
VSCODE_USER="/mnt/c/Users/$WIN_USER/AppData/Local/Programs/Microsoft VS Code/bin"
VSCODE_SYS="/mnt/c/Program Files/Microsoft VS Code/bin"
# Add whichever exists to PATH
if [ -d "$VSCODE_USER" ]; then
export PATH="$PATH:$VSCODE_USER"
elif [ -d "$VSCODE_SYS" ]; then
export PATH="$PATH:$VSCODE_SYS"
fi