Better....

Better Edit-DokcerCompose (suppress errors when permissions don't allow)
Better aliases (eds and edc)
Better Git commands.
This commit is contained in:
lksz 2021-09-10 01:20:12 -04:00
parent 86fdee1acc
commit 33b4c5166b
7 changed files with 59 additions and 7 deletions

View File

@ -0,0 +1,9 @@
[CmdletBinding()]param(
[switch]$NoClearScreen,
[string]$DataSet = 'szmedia/nextcloud',
[string]$DestBackupRoot = '_gw:z/szbackup'
)
if( -not $NoClearScreen ) { Clear-Host }
Write-Verbose "& syncoid --recursive `$DataSet{'$DataSet'} `"`$DestBackupRoot/`$DataSet`"{`"$DestBackupRoot/$DataSet`"}"
& syncoid --recursive $DataSet "$DestBackupRoot/$DataSet"
Write-Host "`n"*2

View File

@ -0,0 +1,32 @@
[CmdletBinding()]param(
[string[]]$Path
# Path to script
)
BEGIN{}
PROCESS{
foreach( $local:scriptPath in $Path ) {
$rs = [runspacefactory]::CreateRunspace()
$rs.Open()
# Get the AST of the file
$tokens = $errors = $null
$ast = [System.Management.Automation.Language.Parser]::ParseFile(
$scriptPath,
[ref]$tokens,
[ref]$errors)
# Get only function definition ASTs
$functionDefinitions = $ast.FindAll({
param([System.Management.Automation.Language.Ast] $Ast)
$Ast -is [System.Management.Automation.Language.FunctionDefinitionAst] -and
# Class methods have a FunctionDefinitionAst under them as well, but we don't want them.
($PSVersionTable.PSVersion.Major -lt 5 -or
$Ast.Parent -isnot [System.Management.Automation.Language.FunctionMemberAst])
}, $true)
$functionDefinitions
}
}
END{}

1
docker/Aliases/edc.ps1 Normal file
View File

@ -0,0 +1 @@
Edit-MyConfig

1
docker/Aliases/eds.ps1 Normal file
View File

@ -0,0 +1 @@
Edit-MyScript

View File

@ -16,7 +16,7 @@ foreach( $local:ext in @('.yml', '.yaml') ) {
$local:testPath = Join-Path $path $fileName $local:testPath = Join-Path $path $fileName
if( $Force -or $(Test-Path $testPath) ) { if( $Force -or $(Test-Path $testPath) ) {
$editFiles += $testPath | Get-Path $editFiles += $testPath | Get-Path
$editFiles += Get-ChildItem $(Join-Path $path '*') -Include $EditBonus -Depth 1 | $editFiles += Get-ChildItem $(Join-Path $path '*') -Include $EditBonus -Depth 1 -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty FullName Select-Object -ExpandProperty FullName
} }
} }

View File

@ -3,10 +3,11 @@
[string]$LocalPath, [string]$LocalPath,
[Parameter(Mandatory)] [Parameter(Mandatory)]
[string]$GitOrigin, [string]$GitOrigin,
[string]$Branch='HEAD' [string]$Branch='HEAD',
[switch]$sudo
) )
$local:gitPath = Join-Path 'themes' 'plextheme' | Get-Path $local:gitPath = Join-Path 'themes' 'plextheme' | Get-Path
function doGit { git "--git-dir=`"$(Join-Path $LocalPath '.git')`"" "--work-tree=`"$LocalPath`"" $args } function doGit { & $(if($sudo){"sudo"}) git "--git-dir=`"$(Join-Path $LocalPath '.git')`"" "--work-tree=`"$LocalPath`"" $args }
$local:savedErrorActionPreference = $ErrorActionPreference $local:savedErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$local:exists = Test-Path $LocalPath $local:exists = Test-Path $LocalPath

View File

@ -1,7 +1,15 @@
$local:workTree = git worktree list --porcelain | Select-String worktree | ForEach-Object { $_ -split 'worktree ' } | Where-Object { $_ } [CmdletBinding(SupportsShouldProcess)]param(
[switch]$sudo
)
$local:workTree = git worktree list --porcelain |
Select-String worktree |
ForEach-Object { $_ -split 'worktree ' } |
Where-Object { $_ }
$local:sudoCmd = [string]::Empty
if( $sudo ) { $sudoCmd = "env sudo" }
Push-Location $workTree Push-Location $workTree
$null = git reset HEAD $null = Invoke-Expression "& $sudoCmd git reset HEAD 2>&1"
$null = git rm --cached -r . $null = Invoke-Expression "& $sudoCmd git rm --cached -r . 2>&1"
$null = git add . $null = Invoke-Expression "& $sudoCmd git add . 2>&1"
git status git status
Pop-Location Pop-Location