A lot of changes
+ PowerLine prompt now shows degraded systemctl state (When Apllicable) + Get-PlexInfo notifies if PLEX creds are needed and are missing + XDG env are setup if missing on linux + vi/vim command will launch editor, but prefer vi/vim/nvim if exists + new chezmoi package: auto loading completion + new flatpak package: List and Kill commands added + new zfs package: zls command added
This commit is contained in:
parent
cdabbc7858
commit
4bf2ff19f4
|
@ -34,6 +34,14 @@ $local:MyPowerLineSetup = [ordered]@{
|
|||
Prompt = @(
|
||||
{ Write-Host "" } # A spaced line without a ColorSeparator
|
||||
{ New-PromptText -EBg VioletRed4 $MyInvocation.HistoryId }
|
||||
{
|
||||
if( Get-Command systemctl -ErrorAction Ignore ) {
|
||||
$local:systemState = systemctl is-system-running
|
||||
if( $systemState -ine 'RUNNING') {
|
||||
New-PromptText -BackgroundColor VioletRed4 $systemState
|
||||
}
|
||||
}
|
||||
}
|
||||
{ Get-SegmentedPath -LengthLimit 37 }
|
||||
{ Write-VcsStatus }
|
||||
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
param([switch]$FetchFromServer,[string]$PlexHost='localhost',[switch]$PassThruOnly)
|
||||
param([switch]$FetchFromServer,[string]$PlexHost,[PSCredential]$Credential,[switch]$PassThruOnly)
|
||||
|
||||
$local:content = $(try{(Get-Content /run/plex.stream.counter/sessions -Raw -ErrorAction Stop)}catch{})
|
||||
|
||||
if( $FetchFromServer ) {
|
||||
$local:creds = New-Object System.Management.Automation.PsCredential($env:PLEX_USERNAME,$(ConvertTo-SecureString -AsPlainText $env:PLEX_PASSWORD -Force))
|
||||
$local:webResp = Invoke-WebRequest -Headers @{ "Content-Length" = "0"; "X-Plex-Client-Identifier" = "my-app" } -Credential $creds -Method Post -Uri "https://my.plexapp.com/users/sign_in.xml"
|
||||
if( ! $PlexHost ) { $PlexHost = $env:PLEX_HOST }
|
||||
if( ! $PlexHost ) { $PlexHost = 'localhost' }
|
||||
|
||||
if( -not Credential ) { $Credential = $PlexPresetCredential }
|
||||
if( -not Credential ) {
|
||||
if( -not $env:PLEX_USERNAME -or -not $env:PLEX_PASSWORD ) {
|
||||
throw "`$env:PLEX_USERNAME AND `$env:PLEX_PASSWORD must be defined in order to read directly from server"
|
||||
}
|
||||
$Credential = New-Object System.Management.Automation.PsCredential($env:PLEX_USERNAME,$(ConvertTo-SecureString -AsPlainText $env:PLEX_PASSWORD -Force))
|
||||
}
|
||||
$local:webResp = Invoke-WebRequest -Headers @{ "Content-Length" = "0"; "X-Plex-Client-Identifier" = "my-app" } -Credential $Credential -Method Post -Uri "https://my.plexapp.com/users/sign_in.xml"
|
||||
$local:plexHeaders = @{ "X-Plex-Token" = ([xml]$webResp.Content).user.authenticationToken }
|
||||
$webResp = Invoke-WebRequest -Headers $plexHeaders "http://${PlexHost}:32400"
|
||||
$local:plexVersion = ([xml]$webResp.Content).MediaContainer.version
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# Setting some defaults based on
|
||||
# FreeDesktop.org's XDG Base Directory Specification document:
|
||||
# https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
|
||||
if( -not (Test-Path env:XDG_DATA_HOME) ) {
|
||||
$env:XDG_DATA_HOME="$HOME/.local/share"
|
||||
}
|
||||
if( -not (Test-Path env:XDG_CONFIG_HOME) ) {
|
||||
$env:XDG_CONFIG_HOME="$HOME/.config"
|
||||
}
|
|
@ -1 +1 @@
|
|||
Edit-TextFile
|
||||
prefervi
|
|
@ -1 +1 @@
|
|||
Edit-TextFile
|
||||
prefervi
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[switch]$sudo,
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName, ValueFromPipeline, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$Path
|
||||
[string[]]$Path,
|
||||
[string[]]$PreferredEditors
|
||||
)
|
||||
|
||||
begin {
|
||||
|
@ -15,7 +16,9 @@ process {
|
|||
}
|
||||
|
||||
end {
|
||||
$local:editors = $env:EDITOR,'nvim','codium','code'
|
||||
$local:editors = $PreferredEditors + @(
|
||||
$env:EDITOR, 'nvim', 'vim', 'vi', 'codium', 'code', 'notepad'
|
||||
) | Where-Object { $_ }
|
||||
$local:editor = $null
|
||||
foreach ( $local:testEditor in $editors ) {
|
||||
if ( $(try { Get-Command -ListImported -Type Application $testEditor -ErrorAction SilentlyContinue }catch {}) ) {
|
||||
|
@ -24,7 +27,7 @@ end {
|
|||
}
|
||||
}
|
||||
|
||||
if( $editor -match 'vim?"$' ) {
|
||||
if ( $editor -match 'vim"$' ) {
|
||||
$editor += ' -p'
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[switch]$sudo,
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName, ValueFromPipeline, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$Path
|
||||
)
|
||||
Edit-TextFile -sudo:$sudo -PreferredEditors "nvim","vim","vi" -Path $Path
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"package": {
|
||||
"Name": "chezmoi",
|
||||
"Condition": [
|
||||
{
|
||||
"custom": null,
|
||||
"System": null,
|
||||
"Hostname": null,
|
||||
"Username": null,
|
||||
"CmdletExists": null,
|
||||
"ModuleExists": null,
|
||||
"AppExeExists": [
|
||||
"chezmoi"
|
||||
],
|
||||
"Logic": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
chezmoi completion powershell | Out-String | iex
|
|
@ -0,0 +1 @@
|
|||
Get-FlatpakInstance
|
|
@ -0,0 +1,27 @@
|
|||
[CmdletBinding()]param(
|
||||
[string[]]$Instance, [string[]]$Application, [string[]]$Runtime
|
||||
)
|
||||
|
||||
$local:cols = [ordered]@{
|
||||
'instance'= 'Instance'
|
||||
'pid'= 'PID'
|
||||
'application'= 'Application'
|
||||
'runtime' = 'Runtime'
|
||||
}
|
||||
|
||||
$local:paks = @(
|
||||
$($cols.Values -join "`t")) + $(
|
||||
flatpak ps "--columns=$($cols.Keys -join ',')"
|
||||
) -join "`n" |
|
||||
ConvertFrom-Csv -Delimiter "`t" |
|
||||
Where-Object {
|
||||
$local:p = $_
|
||||
(-not $Instance -or $( $_ -in $Instance )
|
||||
) -and (-not $Application -or $(
|
||||
$Application | Where-Object { $($p.Application) -match $_ }
|
||||
)) -and (-not $Runtime -or $(
|
||||
$Runtime | Where-Object { $($p.Runtime) -match $_ }
|
||||
))
|
||||
}
|
||||
|
||||
$paks
|
|
@ -0,0 +1,14 @@
|
|||
[CmdletBinding(SupportsShouldProcess,ConfirmImpact='low')]param(
|
||||
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,ValueFromRemainingArguments)]
|
||||
[string[]]$Instance
|
||||
)
|
||||
|
||||
BEGIN {}
|
||||
PROCESS {
|
||||
$Instance | ForEach-Object {
|
||||
if ($PSCmdlet.ShouldProcess("$_", "Kill-FlatpackInstance")) {
|
||||
Write-Verbose "Performing: flatpak kill $_"
|
||||
flatpak kill $_
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"package": {
|
||||
"Name": "flatpak",
|
||||
"Condition": [
|
||||
{
|
||||
"custom": null,
|
||||
"System": null,
|
||||
"Hostname": null,
|
||||
"Username": null,
|
||||
"CmdletExists": null,
|
||||
"ModuleExists": null,
|
||||
"AppExeExists": [
|
||||
"flatpak"
|
||||
],
|
||||
"Logic": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"package": {
|
||||
"Condition": [
|
||||
{
|
||||
"custom": null,
|
||||
"System": null,
|
||||
"Hostname": null,
|
||||
"Username": null,
|
||||
"CmdletExists": null,
|
||||
"ModuleExists": null,
|
||||
"AppExeExists": [
|
||||
"zfs"
|
||||
],
|
||||
"Logic": 0
|
||||
}
|
||||
],
|
||||
"Name": "zfs"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
$local:prev = "";
|
||||
zfs list -o name,used,avail,refer,canmount,mounted,mountpoint $args |
|
||||
grep -v 'docker/' |
|
||||
ForEach-Object {
|
||||
$local:tmpPrev = $_ -replace '^(\w+(\W\w+(\W\w+)?)?).*','$1';
|
||||
if( $tmpPrev -notmatch "^$prev" -and $prev -notin ('','NAME') ) {
|
||||
'-----------------'
|
||||
};
|
||||
$prev = $tmpPrev;
|
||||
$_
|
||||
}
|
Loading…
Reference in New Issue