scripts: created pwsh launch script
This commit is contained in:
parent
c5625bf46c
commit
dd299c4976
3 changed files with 29 additions and 0 deletions
|
@ -29,5 +29,6 @@ A feature-barren DOS clone of `ls` that hides Windows hidden files. Relies on
|
||||||
- `dos.sh`: Simple wrapper for executing Windows commands directly.
|
- `dos.sh`: Simple wrapper for executing Windows commands directly.
|
||||||
- `elevate.sh`: Elevate WSL (`-l`) or Windows (`-w`) commands from WSL.
|
- `elevate.sh`: Elevate WSL (`-l`) or Windows (`-w`) commands from WSL.
|
||||||
- `explorer.sh`: Launch explorer from WSL.
|
- `explorer.sh`: Launch explorer from WSL.
|
||||||
|
- `pwsh.sh`: Launch PowerShell Core.
|
||||||
- `terminal.sh`: Launch Windows Terminal.
|
- `terminal.sh`: Launch Windows Terminal.
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,6 @@ install DIR="~/.bin":
|
||||||
cp dos.sh {{DIR}}/dos
|
cp dos.sh {{DIR}}/dos
|
||||||
cp elevate.sh {{DIR}}/elevate
|
cp elevate.sh {{DIR}}/elevate
|
||||||
cp explorer.sh {{DIR}}/explorer
|
cp explorer.sh {{DIR}}/explorer
|
||||||
|
cp pwsh.sh {{DIR}}/pwsh
|
||||||
cp terminal.sh {{DIR}}/terminal
|
cp terminal.sh {{DIR}}/terminal
|
||||||
|
|
||||||
|
|
27
scripts/pwsh.sh
Executable file
27
scripts/pwsh.sh
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# try to use system-wide version first.
|
||||||
|
# this usually fails, but it's worth a shot.
|
||||||
|
if [[ -r '/mnt/c/Program Files/WindowsApps/' ]]; then
|
||||||
|
cd '/mnt/c/Program Files/WindowsApps/'
|
||||||
|
PWSH="`pwd`/`find Microsoft.PowerShell_* -name 'pwsh.exe'`"
|
||||||
|
cd - > /dev/null
|
||||||
|
if ! [ -x "$PWSH" ]; then
|
||||||
|
unset PWSH
|
||||||
|
fi
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run target
|
||||||
|
"$PWSH" $@
|
||||||
|
|
Loading…
Reference in a new issue