Adding common commands + Minor modifications
Reload-MyScripts modified to check for past aliases that might block it from working. Aliases dir created with some basic aliases Invoke-Sudo to make sudo command line calling simpler.
This commit is contained in:
parent
38aa7720de
commit
968b6c2bbb
|
@ -0,0 +1 @@
|
|||
Edit-TextFile
|
|
@ -0,0 +1 @@
|
|||
Edit-TextFile
|
|
@ -0,0 +1 @@
|
|||
Edit-TextFile
|
|
@ -0,0 +1 @@
|
|||
Edit-TextFile
|
|
@ -0,0 +1,2 @@
|
|||
param([string]$Base64String)
|
||||
return [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($Base64String))
|
|
@ -66,7 +66,8 @@ if( -not $ScriptPaths ) {
|
|||
foreach( $local:p in $ScriptPaths ) {
|
||||
$local:parentPath = Split-Path -Parent $p;
|
||||
if( -not (Test-Path $p) -and -not (Test-Path $parentPath) ) {
|
||||
New-Item -Directory $parentPath
|
||||
Write-Verbose "Creating missing path $parentPath..."
|
||||
New-Item -Type Directory $parentPath
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[Parameter(Mandatory = $true,Position = 0, ValueFromRemainingArguments = $true)]
|
||||
$expr
|
||||
)
|
||||
|
||||
. Invoke-ExpressionEx -sudo $expr
|
|
@ -1,5 +1,6 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param()
|
||||
|
||||
try { Get-Alias Get-MyAliases -ErrorAction Stop | ForEach-Object { Remove-Item "Alias:$($_.Name)" } } catch {}
|
||||
function Get-MyAliases {
|
||||
[CmdletBinding(SupportsShouldProcess)]param([switch]$ScriptsOnly)
|
||||
|
||||
|
@ -29,9 +30,13 @@ function Get-MyAliases {
|
|||
$allAliases
|
||||
}
|
||||
|
||||
function getScriptName{param([string]$FullPath)
|
||||
$FullPath -replace '\.ps1$','' -replace "^$([regex]::Escape($MyPSScriptRoot)).",''
|
||||
}
|
||||
|
||||
$local:myAliases = [ordered]@{}
|
||||
if( Test-Path $(Join-Path $MyPSScriptRoot Aliases) ) {
|
||||
Get-ChildItem Join-Path (Join-Path $MyPSScriptRoot Aliases) | ForEach-Object {
|
||||
Get-ChildItem $(Join-Path $MyPSScriptRoot Aliases) | ForEach-Object {
|
||||
$myAliases[$_.BaseName] = Get-Content $_
|
||||
}
|
||||
}
|
||||
|
@ -56,14 +61,14 @@ if( Get-Command Remove-Alias -ErrorAction SilentlyContinue ) {
|
|||
|
||||
if( $(. Get-ScopeDepth) -gt 0 ) { Write-Host -ForegroundColor Red "Try sourcing Reload-MyScripts instead of just running it" }
|
||||
Get-ChildItem $(Join-Path $MyPSScriptRoot profile.d) -Filter '*.ps1' | ForEach-Object {
|
||||
Write-Verbose "Loading $($_.FullName -replace '\.ps1$','' -replace "^$([regex]::Escape($MyPSScriptRoot)).",'')...";
|
||||
Write-Verbose "Loading $(getScriptName $_.FullName)...";
|
||||
". '$($_.FullName)';"
|
||||
} | Invoke-Expression
|
||||
|
||||
$local:CommandsToAlias = (
|
||||
@( $MyPSScriptRoot ) + $(
|
||||
[SystemName]::_GetValidValues("",$true,$true) | ForEach-Object {
|
||||
Join-Path $MyPSScriptRoot $_
|
||||
Join-Path $MyPSScriptRoot "sys.$_"
|
||||
}
|
||||
)) | ForEach-Object {
|
||||
if( Test-Path $_ ) {
|
||||
|
@ -72,10 +77,12 @@ $local:CommandsToAlias = (
|
|||
}
|
||||
|
||||
$CommandsToAlias | ForEach-Object {
|
||||
Write-Verbose "Creating alias for $(getScriptName $_.FullName) Script..."
|
||||
Set-Alias $($_.BaseName) $_.FullName -Scope $MyAliasScope
|
||||
}
|
||||
|
||||
foreach( $local:alias in $myAliases.Keys ) {
|
||||
Write-Verbose "Adding $($alias) alias..."
|
||||
Set-Alias -Name $alias -Value $myAliases[$alias] -Description '#MyAlias' -Scope $MyAliasScope
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[CmdletBinding()]param([string[]]$OrderBy,[switch]$PassThru)
|
||||
|
||||
$local:result = $(docker ps --format='{{ .Image }}\t{{ .Names }}\t{{ .Status }}\t{{ .Ports }}' | ForEach-Object { $local:l = $_ -split '\t'; [PSCustomObject](@{Image=$l[0];Names=$l[1];Status=$l[2];Ports=$l[3] -replace ', ',"
|
||||
"}) } ) | Sort-Object Names
|
||||
|
||||
if( $OrderBy ) {
|
||||
$result = $result | Sort-Object $OrderBy
|
||||
}
|
||||
|
||||
if( $PassThru ) { return $result }
|
||||
$result | Format-Table -Wrap -Property Image,Names,Status,Ports
|
|
@ -0,0 +1,4 @@
|
|||
$local:params = $args -join ' '
|
||||
if( -not $params ) { $params = '-la' }
|
||||
/usr/bin/env ls $params
|
||||
|
|
@ -1,2 +1 @@
|
|||
|
||||
Invoke-ExpressionEx -sudo "`$env:TERM='tmux-256color'; `$env:EDITOR='$env:EDITOR'; ranger"
|
||||
Invoke-ExpressionEx -sudo "`$env:TERM='tmux-256color'; `$env:EDITOR='$env:EDITOR'; ranger $args"
|
||||
|
|
Loading…
Reference in New Issue