Code Fix
This commit is contained in:
parent
c5ce8107ac
commit
b14dccdae0
21
.zsh_aliases
21
.zsh_aliases
@ -53,13 +53,20 @@ if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null; then
|
|||||||
alias open="/mnt/c/Windows/explorer.exe" # Mac-style 'open' command
|
alias open="/mnt/c/Windows/explorer.exe" # Mac-style 'open' command
|
||||||
|
|
||||||
# 2. VS Code (Dynamic Alias)
|
# 2. VS Code (Dynamic Alias)
|
||||||
# This finds the username automatically so it works on any Windows machine
|
if [ -f "/mnt/c/Windows/System32/cmd.exe" ]; then
|
||||||
_WIN_USER=$(cmd.exe /c 'echo %USERNAME%' 2>/dev/null | tr -d '\r')
|
_WIN_USER=$(/mnt/c/Windows/System32/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
|
# Only proceed if we actually got a username back
|
||||||
alias code="/mnt/c/Users/$_WIN_USER/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code"
|
if [ -n "$_WIN_USER" ]; then
|
||||||
elif [ -d "/mnt/c/Program Files/Microsoft VS Code/bin" ]; then
|
USER_CODE="/mnt/c/Users/$_WIN_USER/AppData/Local/Programs/Microsoft VS Code/bin/code"
|
||||||
alias code="/mnt/c/Program\ Files/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
|
||||||
|
|
||||||
fi
|
fi
|
||||||
Loading…
x
Reference in New Issue
Block a user