Setup WSL Bash with PowerShell Core in PrimalScript
- Details
- Written by Max Trinidad
- Last Updated: 23 August 2019
- Created: 22 January 2018
- Hits: 7150
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.
bash /home/maxt/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:
bash /home/maxt/pwsh-nonAdmin
*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.
Additional Tips
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.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.