summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJohn Parent <john.parent@kitware.com>2022-03-16 16:43:04 -0400
committerPeter Scheibel <scheibel1@llnl.gov>2022-03-17 09:01:01 -0700
commit99c1f9b987ebe3a1801c62aa9e417f8ea34d08a5 (patch)
treea75ebeb1446e86208bcd5566cff791f9499ff93f /bin
parent4aee27816e7101753aeb392e868096236a26d84d (diff)
downloadspack-99c1f9b987ebe3a1801c62aa9e417f8ea34d08a5.tar.gz
spack-99c1f9b987ebe3a1801c62aa9e417f8ea34d08a5.tar.bz2
spack-99c1f9b987ebe3a1801c62aa9e417f8ea34d08a5.tar.xz
spack-99c1f9b987ebe3a1801c62aa9e417f8ea34d08a5.zip
PWSH Support
Include support for powershell Prepend cmd and pwsh with [spack] to denote spack enabled shell
Diffstat (limited to 'bin')
-rw-r--r--bin/spack_pwsh.ps159
1 files changed, 59 insertions, 0 deletions
diff --git a/bin/spack_pwsh.ps1 b/bin/spack_pwsh.ps1
new file mode 100644
index 0000000000..199d33038c
--- /dev/null
+++ b/bin/spack_pwsh.ps1
@@ -0,0 +1,59 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+Push-Location $PSScriptRoot/..
+$Env:SPACK_ROOT = $PWD.Path
+Push-Location $PWD/..
+$Env:spackinstdir = $PWD.Path
+Pop-Location
+
+Set-Variable -Name python_pf_ver -Value (Get-Command -Name python -ErrorAction SilentlyContinue).Path
+
+# If python_pf_ver is not defined, we cannot find Python on the Path
+# We next look for Spack vendored copys
+if ($null -eq $python_pf_ver)
+{
+ $python_pf_ver_list = Resolve-Path -Path "$PWD\Python*"
+ if ($python_pf_ver_list.Length -gt 0)
+ {
+ $py_path = $python_pf_ver_list[$python_pf_ver_list.Length-1].Path
+ $py_exe = "$py_path\python.exe"
+ }
+ else {
+ Write-Error -Message "Python was not found on system"
+ Write-Output "Please install Python or add Python to the PATH"
+ }
+}
+else{
+ Set-Variable -Name py_exe -Value $python_pf_ver
+}
+
+if (!$null -eq $py_path)
+{
+ $Env:Path = "$py_path;$Env:Path"
+}
+
+if (!$null -eq $py_exe)
+{
+ Invoke-Expression "$py_exe" "$Env:SPACK_ROOT\bin\haspywin.py"
+ Invoke-Expression "$py_exe" "$Env:SPACK_ROOT\bin\spack external find python" | Out-Null
+}
+
+$Env:Path = "$Env:SPACK_ROOT\bin;$Env:Path"
+$Env:EDITOR = "notepad"
+
+
+Write-Output "*****************************************************************"
+Write-Output "**************** Spack Package Manager **************************"
+Write-Output "*****************************************************************"
+
+$command = 'function global:prompt
+{
+ $pth = $(Convert-Path $(Get-Location)) | Split-Path -leaf
+ "[spack] PS $pth>"
+}'
+$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
+$encoded_command = [Convert]::ToBase64String($bytes)
+powershell.exe -NoLogo -encodedCommand $encoded_command -NoExit