scripts: removed 'userprofile' script in favor of 'dos-var'

This commit is contained in:
Valerie Wolfe 2024-07-12 14:32:26 -04:00
parent 3fd510a45c
commit 32731b72b1
4 changed files with 11 additions and 12 deletions

View file

@ -40,5 +40,4 @@ A feature-barren DOS clone of `ls` that hides Windows hidden files. Relies on
- `explorer.sh`: Launch explorer from WSL.
- `pwsh.sh`: Launch PowerShell Core.
- `terminal.sh`: Launch Windows Terminal.
- `userprofile.sh`: Get the Windows user profile directory (`%USERPROFILE%`).

10
dos-var/justfile Normal file
View file

@ -0,0 +1,10 @@
alias b := build
alias i := install
build:
cargo build --release
install DIR: build
cp ./target/release/dos-var "{{DIR}}/dos-var"

View file

@ -13,7 +13,7 @@ fi
# fall back to user installation
if [ -z ${PWSH+x} ]; then
PWSH="`userprofile`/AppData/Local/Microsoft/WindowsApps/pwsh.exe"
PWSH="`dos-var -p USERPROFILE`/AppData/Local/Microsoft/WindowsApps/pwsh.exe"
fi
# run target

View file

@ -1,10 +0,0 @@
#!/usr/bin/bash
# absolutely monstrous string hackery
# get %USERPROFILE% using cmd and convert that path
USERPROFILE=`/mnt/c/Windows/System32/cmd.exe '/C' 'echo %USERPROFILE%' 2> /dev/null`
USERPROFILE=${USERPROFILE//\\//} # replace '\' separators with '/'
USERPROFILE=/mnt/c/${USERPROFILE#C:/} # replace 'C:/' with '/mnt/c/'
USERPROFILE=${USERPROFILE%$'\r'} # strip carriage return
echo $USERPROFILE