Streamlined pwsz loading from Linux shells
Get-Path updated to support @ notation. MyConfig class updated to resolve Paths before testing. MyScript class will look recursivley - this might need to change again. config.files.json updated to support shell-loading-snippets shell-loading-snippets added, with single line of code to inject into startup shell scripts (.zshrc, .bashrc, .shrc)
This commit is contained in:
parent
e34d9d4e4d
commit
c6cc116564
|
@ -1,6 +1,9 @@
|
||||||
[CmdletBinding()]param([string]$Path)
|
[CmdletBinding()]param([string]$Path)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if( $Path[0] -eq '@' ) {
|
||||||
|
$Path = Join-Path $MyPSScriptRoot $Path.Substring(1)
|
||||||
|
}
|
||||||
get-item $Path -Force -ErrorAction Stop |
|
get-item $Path -Force -ErrorAction Stop |
|
||||||
Select-Object -ExpandProperty FullName
|
Select-Object -ExpandProperty FullName
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -39,9 +39,10 @@ class MyConfig { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||||
$local:exists = $false;
|
$local:exists = $false;
|
||||||
$local:first = $null
|
$local:first = $null
|
||||||
foreach( $local:configPath in $flatConfigList ) {
|
foreach( $local:configPath in $flatConfigList ) {
|
||||||
|
$configPath = Get-Path $configPath
|
||||||
if( -not $first ) { $first = $configPath }
|
if( -not $first ) { $first = $configPath }
|
||||||
if( $Force -or (Test-Path $configPath) ) {
|
if( $Force -or (Test-Path $configPath) ) {
|
||||||
$result += Get-Path $configPath
|
$result += $configPath
|
||||||
$exists = $true
|
$exists = $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ class MyScript { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||||
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$CurrentOnly,[bool]$Strict) {
|
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$CurrentOnly,[bool]$Strict) {
|
||||||
$local:possibleValues = $(
|
$local:possibleValues = $(
|
||||||
Get-MyPackages -ReturnFullPath -IncludeRoot -Force:$(-not $CurrentOnly) |
|
Get-MyPackages -ReturnFullPath -IncludeRoot -Force:$(-not $CurrentOnly) |
|
||||||
Get-ChildItem -Filter '*.ps1' |
|
Get-ChildItem -Recurse -Filter '*.ps1' |
|
||||||
Select-Object -ExpandProperty FullName | ForEach-Object {
|
Select-Object -ExpandProperty FullName | ForEach-Object {
|
||||||
$_ -replace '\.ps1$','' -replace "$($MyPSScriptRoot -replace '\\',"\\")[/\\]",''
|
$_ -replace '\.ps1$','' -replace "$($MyPSScriptRoot -replace '\\',"\\")[/\\]",''
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"vi": "~/.virc",
|
"vi": "~/.virc",
|
||||||
"sz-local-rc": "~/.sz.local.sh",
|
"sz-local-rc": "~/.sz.local.sh",
|
||||||
"zshrc": "~/.zshrc",
|
"zshrc": "~/.zshrc",
|
||||||
|
"shrc": "~/.shrc",
|
||||||
"ansible": [
|
"ansible": [
|
||||||
"/etc/ansible/ansible.cfg",
|
"/etc/ansible/ansible.cfg",
|
||||||
"/opt/ansible/ansible.cfg",
|
"/opt/ansible/ansible.cfg",
|
||||||
|
@ -26,9 +27,15 @@
|
||||||
"~/.vimrc",
|
"~/.vimrc",
|
||||||
"~/.vim/vimrc"
|
"~/.vim/vimrc"
|
||||||
],
|
],
|
||||||
|
"sz-shrc": [
|
||||||
|
"#shrc",
|
||||||
|
"@shell-loading-snippets/bash",
|
||||||
|
"@shell-loading-snippets/sh"
|
||||||
|
],
|
||||||
"sz-zshrc": [
|
"sz-zshrc": [
|
||||||
"~/.sz.zshrc.sh",
|
"~/.sz.zshrc.sh",
|
||||||
"#zshrc"
|
"#zshrc",
|
||||||
|
"@shell-loading-snippets/zsh"
|
||||||
],
|
],
|
||||||
"tmux": [
|
"tmux": [
|
||||||
"~/.tmux.conf",
|
"~/.tmux.conf",
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
## Place the following line at the top of your .zshrc to make powershell your default shell.
|
||||||
|
# local P=".local/share/powershell/Scripts/shell-loading-snippets/$(basename $SHELL)"; find ~/$P -exec echo 'Starting PowerShell SZcripts...' \; && . ~/$P
|
||||||
|
|
||||||
|
if [[ -x ~/.dotnet/tools/pwsh && "1" != "$(which pwsh > /dev/null && echo 1)" ]]; then
|
||||||
|
PWSH='~/.dotnet/tools/pwsh'
|
||||||
|
alias pwsh="$PWSH "
|
||||||
|
|
||||||
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
fi
|
||||||
|
echo "$(date) SZ_SKIP_DEFAULT_SHELL='$SZ_SKIP_DEFAULT_SHELL'; pwsh: $(which pwsh); Setup-Profile: $(ls ~/.local/share/powershell/Scripts/base/Setup-Profile.ps1) " >> /tmp/default_shell
|
||||||
|
if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" && "1" == "$(which pwsh > /dev/null && echo 1)" && -f ~/.local/share/powershell/Scripts/base/Setup-Profile.ps1 ]]; then
|
||||||
|
echo "pwsh" >> /tmp/default_shell
|
||||||
|
pwsh
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "continue" >> /tmp/default_shell
|
||||||
|
export SZ_SKIP_DEFAULT_SHELL=1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
## Place the following line at the top of your .zshrc to make powershell your default shell.
|
||||||
|
# local P=".local/share/powershell/Scripts/shell-loading-snippets/$(basename $SHELL)"; find ~/$P -exec echo 'Starting PowerShell SZcripts...' \; && . ~/$P
|
||||||
|
|
||||||
|
if [[ -x ~/.dotnet/tools/pwsh && "1" != "$(which pwsh > /dev/null && echo 1)" ]]; then
|
||||||
|
PWSH='~/.dotnet/tools/pwsh'
|
||||||
|
alias pwsh="$PWSH "
|
||||||
|
|
||||||
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
fi
|
||||||
|
echo "$(date) SZ_SKIP_DEFAULT_SHELL='$SZ_SKIP_DEFAULT_SHELL'; pwsh: $(which pwsh); Setup-Profile: $(ls ~/.local/share/powershell/Scripts/base/Setup-Profile.ps1) " >> /tmp/default_shell
|
||||||
|
if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" && "1" == "$(which pwsh > /dev/null && echo 1)" && -f ~/.local/share/powershell/Scripts/base/Setup-Profile.ps1 ]]; then
|
||||||
|
echo "pwsh" >> /tmp/default_shell
|
||||||
|
pwsh
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "continue" >> /tmp/default_shell
|
||||||
|
export SZ_SKIP_DEFAULT_SHELL=1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
## Place the following line at the top of your .zshrc to make powershell your default shell.
|
||||||
|
# local P=".local/share/powershell/Scripts/shell-loading-snippets/$(basename $SHELL)"; find ~/$P -exec echo 'Starting PowerShell SZcripts...' \; && . ~/$P
|
||||||
|
|
||||||
|
if [[ -x ~/.dotnet/tools/pwsh && "1" != "$(which pwsh > /dev/null && echo 1)" ]]; then
|
||||||
|
PWSH='~/.dotnet/tools/pwsh'
|
||||||
|
alias pwsh="$PWSH "
|
||||||
|
|
||||||
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
fi
|
||||||
|
echo "$(date) SZ_SKIP_DEFAULT_SHELL='$SZ_SKIP_DEFAULT_SHELL'; pwsh: $(which pwsh); Setup-Profile: $(ls ~/.local/share/powershell/Scripts/base/Setup-Profile.ps1) " >> /tmp/default_shell
|
||||||
|
if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" && "1" == "$(which pwsh > /dev/null && echo 1)" && -f ~/.local/share/powershell/Scripts/base/Setup-Profile.ps1 ]]; then
|
||||||
|
echo "pwsh" >> /tmp/default_shell
|
||||||
|
pwsh
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "continue" >> /tmp/default_shell
|
||||||
|
export SZ_SKIP_DEFAULT_SHELL=1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue