23 lines
791 B
Bash
23 lines
791 B
Bash
#!/usr/bin/env zsh
|
|
|
|
local cmd=${commands[cmd.exe]:-/mnt/c/Windows/System32/cmd.exe}
|
|
[[ -x $cmd ]] || return
|
|
|
|
case "$(</proc/version)" in
|
|
*Microsoft*) typeset -gi z4h_no_flock=1;;
|
|
*microsoft*) ;;
|
|
*) return ;;
|
|
esac
|
|
|
|
local lines=("${(@f)${$(cd -q -- ${cmd:h} && ./${cmd:t} /c set 2>/dev/null)//$'\r'}}")
|
|
local keys=(${lines%%=*}) vals=(${lines#*=})
|
|
typeset -grA z4h_win_env=(${keys:^vals})
|
|
local home=$z4h_win_env[USERPROFILE]
|
|
[[ -n $home ]] || return
|
|
if [[ $home != [a-zA-Z]':\'* ||
|
|
( ! -d ${home::=/mnt/${(L)home[1]}/${${home:3}//\\//}} &&
|
|
! -d ${home::=${home#/mnt}} ) ]]; then
|
|
home=$(command wslpath -- $z4h_win_env[USERPROFILE] 2>/dev/null) || return
|
|
[[ -d $home ]] || return
|
|
fi
|
|
typeset -gr z4h_win_home=$home
|