System specific update
Reload-Scripts now loads Platform/OS specific scripts depending on current state. This required the SystemName class sranger is an example of running ranger as sudo, but only in Linux. Moved Get-MyAliases into Reload-MyScripts, and changed Reload-MyScripts to load Aliases dynamically via the Aliases directory.
This commit is contained in:
parent
45b53dc110
commit
2d2a7bba5d
8 changed files with 150 additions and 43 deletions
18
profile.d/MyConfig.class.ps1
Normal file
18
profile.d/MyConfig.class.ps1
Normal file
|
@ -0,0 +1,18 @@
|
|||
class MyConfig { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||
static [hashtable]$configDirectory = [ordered]@{
|
||||
'vi' = '~/.virc'
|
||||
'vim' = '~/.vimrc','~/.vim/vimrc'
|
||||
'neovim' = '~/.config/nvim/init.vim','~/.config/nvim/vim-plug/plugins.vim','#vim','#vi'
|
||||
}
|
||||
static [string[]] GetConfigPaths([string[]]$ConfigNames) {
|
||||
return $null
|
||||
}
|
||||
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) {
|
||||
$local:possibleValues = [MyConfig]::configDirectory.Keys
|
||||
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues -Strict:$Strict );
|
||||
}
|
||||
|
||||
[String[]] GetValidValues() {
|
||||
return [MyConfig]::_GetValidValues('',$true)
|
||||
}
|
||||
}
|
2
profile.d/Style.ps1
Normal file
2
profile.d/Style.ps1
Normal file
|
@ -0,0 +1,2 @@
|
|||
Get-Command Set-PSReadLineKeyHandler | ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete }
|
||||
Get-Command Set-Theme -ErrorAction SilentlyContinue | ForEach-Object { Set-Theme Paradox }
|
37
profile.d/SystemName.class.ps1
Normal file
37
profile.d/SystemName.class.ps1
Normal file
|
@ -0,0 +1,37 @@
|
|||
class SystemName { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$CurrentOnly,[bool]$Strict) {
|
||||
$MyPSScriptRoot = "$global:MyPSScriptRoot";
|
||||
$local:possibleValues = [ordered]@{}
|
||||
$possibleValues.out = @()
|
||||
$possibleValues.Current = @(
|
||||
$($global:PSVersionTable.OS -split ' '|Select-Object -First 1).Replace('Microsoft','Windows'),
|
||||
$global:PSVersionTable.Platform,
|
||||
$global:PSVersionTable.PSEdition
|
||||
);
|
||||
$possibleValues.out = $possibleValues.Current
|
||||
|
||||
if( -not $CurrentOnly ) {
|
||||
$possibleValues.Platform = @( 'Windows','Linux','Unix' );
|
||||
$possibleValues.Edition = @( 'Desktop', 'Core' );
|
||||
$possibleValues.Exist = Get-ChildItem (Join-Path $MyPSScriptRoot "sys.*") | ForEach-Object { $_.Name -replace 'sys\.','' };
|
||||
$possibleValues.out += $possibleValues.Platform + $possibleValues.Edition + $possibleValues.Exist
|
||||
}
|
||||
$possibleValues.out = $possibleValues.out |
|
||||
Select-Object -Unique |
|
||||
Sort-Object {
|
||||
$local:sortName = "zz_$_";
|
||||
if( $_ -in $possibleValues.Exist -and $_ -in $possibleValues.Current ) { $sortName[0] = "a" }
|
||||
elseif( $_ -in $possibleValues.Exist ) { $sortName[0] = "b" }
|
||||
elseif( $_ -in $possibleValues.Current ) { $sortName[0] = "c" }
|
||||
if( $_ -in $possibleValues.Platform ) { $sortName[1] = "a" }
|
||||
if( $_ -in $possibleValues.Edition ) { $sortName[1] = "b" }
|
||||
$sortName;
|
||||
}
|
||||
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues.out -Strict:$Strict );
|
||||
}
|
||||
|
||||
[String[]] GetValidValues() {
|
||||
return [SystemName]::_GetValidValues('',$false,$true)
|
||||
}
|
||||
}
|
||||
|
4
profile.d/UnixCompleters.ps1
Normal file
4
profile.d/UnixCompleters.ps1
Normal file
|
@ -0,0 +1,4 @@
|
|||
Get-Command Import-UnixCompleters -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
Import-UnixCompleters
|
||||
Set-UnixCompleter -ShellType Zsh
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue