Setup WSL Bash with PowerShell Core in PrimalScript
- Written by Max Trinidad
- Last Updated: 23 August 2019
- Created: 22 January 2018
- Hits: 5787
In this article, we examine setting up WSL (Windows Subsystem for Linux) Bash with PowerShell Core in PrimalScript’s Console Window list.
Prepare Bash File
In order to open PowerShell Core in Linux, the bash shell needs to be open and pwsh should be run from the console. So, a bash file needs to be created to call Powershell Core.
1. In Windows 10 (Build 16299 or higher), from the start menu, open the Ubuntu Bash console.
2. Use a Linux text editor (emacs24 or vim) to create the following bash file as pwsh-nonAdmin, and save the file:
pwsh -NoExit -Command Remove-Module PSReadLine
3. Test by executing the Linux bash file pwsh-nonAdmin.
Adding the Bash file to PrimalScript
Follow the same steps from this article:
SAPIEN Tools – How to work with PowerShell Core in PrimalScript
In this case, I’ve selected my SAPIEN Technologies folder to save this DOS batch file*. Then, I manually entered this line in the Command Line field for the New Shell:
*Note: Make sure to select a folder where this file is safely stored.
Then, follow the same steps from the article, SAPIEN Tools - How to Work with PowerShell Core in PrimalScript, to rename, save, restart, and test the command shell in PrimalScript's Console Window.
It is recommended to setup a second PowerShell Core to execute as Administrator, so the bash file may include the following line:
sudo pswh -NoExit -Command Remove-Module PSReadLine
In the event that cross-platform script files are created, execute the Linux command
dos2unix within Linux. This command will convert text files with DOS (or Mac) line breaks to Unix line breaks.