Compare commits

...

2 commits

Author SHA1 Message Date
190f17f7e2 env-share: created justfile 2024-07-08 13:26:12 -04:00
18389ca9b8 scripts: created userprofile script 2024-07-08 13:25:59 -04:00
5 changed files with 24 additions and 7 deletions

View file

@ -36,4 +36,5 @@ 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%`).

11
env-share/justfile Normal file
View file

@ -0,0 +1,11 @@
alias b := build
alias i := install
build:
cargo build --release
install DIR: build
cp ./target/release/env-share "{{DIR}}/env-share"

View file

@ -7,4 +7,5 @@ install DIR="~/.bin":
cp explorer.sh {{DIR}}/explorer
cp pwsh.sh {{DIR}}/pwsh
cp terminal.sh {{DIR}}/terminal
cp userprofile.sh {{DIR}}/userprofile

View file

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

10
scripts/userprofile.sh Executable file
View file

@ -0,0 +1,10 @@
#!/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