New commands + fixes
+ Get-Mount (mounts retuned as objects for easy filtering) + Get-RandomMacAddress (for easy MAC Address generation) * Get-Path modified to resolve ~, also made it work with pipeline input * Edit-TextFile streamlined by using modified Get-Path * Added emacs and spacemacs to MyConfig * dcup - attempt at cleaner output + added docker/profile.d/env.ps1 for default docker vars
This commit is contained in:
parent
f947b0b3b4
commit
f7df96c55d
|
@ -0,0 +1,14 @@
|
||||||
|
[CmdletBinding()]param()
|
||||||
|
|
||||||
|
& mount |
|
||||||
|
ForEach-Object {
|
||||||
|
$null = $_ -match "^(.*) on (/.*) type ([^ ]*)( (.*))?$";
|
||||||
|
[PSCustomObject]([ordered]@{
|
||||||
|
Path = $matches[2]
|
||||||
|
Type = $matches[3]
|
||||||
|
Name = $matches[1]
|
||||||
|
Options = $matches[5]
|
||||||
|
# Matches = $Matches
|
||||||
|
# Raw = $_
|
||||||
|
})
|
||||||
|
}
|
|
@ -23,11 +23,7 @@ if( $editor -match 'code(\.exe)?$' ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$local:arguments = $($Path | ForEach-Object {
|
$local:arguments = $Path | Get-Path | Join-String -Separator "' '"
|
||||||
if ($Path -match '\*|\?|~') {
|
|
||||||
Get-ChildItem -Path $_ | Select-Object -ExpandProperty FullName
|
|
||||||
} else { $_ }
|
|
||||||
} ) -join "' '"
|
|
||||||
if( $Path ) { $arguments = "'$arguments'" }
|
if( $Path ) { $arguments = "'$arguments'" }
|
||||||
|
|
||||||
if( $PSCmdlet.ShouldProcess( "Edit ($editor): $arguments" ) ) {
|
if( $PSCmdlet.ShouldProcess( "Edit ($editor): $arguments" ) ) {
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
[CmdletBinding()]param([string]$Path)
|
[CmdletBinding()]param(
|
||||||
|
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,Position=0)]
|
||||||
|
[Alias("FullName")]
|
||||||
|
[string[]]$Path
|
||||||
|
)
|
||||||
|
process {
|
||||||
|
|
||||||
function Get-FullPath {
|
function Get-FullPath {
|
||||||
param([string]$Path)
|
param([string]$Path)
|
||||||
|
@ -10,16 +15,24 @@ function Get-FullPath {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $Path[0] -eq '@' ) {
|
foreach( $local:p in $Path ) {
|
||||||
$Path = Join-Path $MyPSScriptRoot $Path.Substring(1)
|
switch( $p[0] ) {
|
||||||
|
'@' { $p = Join-Path $MyPSScriptRoot $p.Substring(1) }
|
||||||
|
'~' {
|
||||||
|
if( $p -match '^~[^/]*' ) {
|
||||||
|
$local:m = $Matches[0]
|
||||||
|
$p = $p -replace "^$m",((Get-Item $m).FullName)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if([System.IO.Path]::IsPathRooted($Path)){
|
if([System.IO.Path]::IsPathRooted($p)){
|
||||||
[System.IO.Path]::GetFullPath($Path)
|
[System.IO.Path]::GetFullPath($p)
|
||||||
}else{
|
}else{
|
||||||
[System.IO.Path]::GetFullPath((Join-Path $PWD $Path))
|
[System.IO.Path]::GetFullPath((Join-Path $PWD $p))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# try {
|
# try {
|
||||||
# get-item $Path -Force -ErrorAction Stop |
|
# get-item $Path -Force -ErrorAction Stop |
|
||||||
# Select-Object -ExpandProperty FullName
|
# Select-Object -ExpandProperty FullName
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[CmdletBinding()]param(
|
||||||
|
[string]$Delimiter=':'
|
||||||
|
)
|
||||||
|
|
||||||
|
$(0..5 | ForEach-Object {
|
||||||
|
'{0:x}{1:x}' -f (
|
||||||
|
Get-Random -Minimum 0 -Maximum 15
|
||||||
|
), (
|
||||||
|
Get-Random -Minimum 0 -Maximum 15
|
||||||
|
)
|
||||||
|
}) -join $Delimiter
|
|
@ -33,6 +33,14 @@
|
||||||
"/opt/ansible/ansible.cfg",
|
"/opt/ansible/ansible.cfg",
|
||||||
"/opt/ansible/hosts"
|
"/opt/ansible/hosts"
|
||||||
],
|
],
|
||||||
|
"emacs": [
|
||||||
|
"~/.emacs",
|
||||||
|
"~/.emacs.d"
|
||||||
|
],
|
||||||
|
"spacemacs": [
|
||||||
|
"~/.spacemacs",
|
||||||
|
"#emacs"
|
||||||
|
],
|
||||||
"vim": [
|
"vim": [
|
||||||
"~/.vimrc",
|
"~/.vimrc",
|
||||||
"~/.vim/vimrc"
|
"~/.vim/vimrc"
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
[switch]$NoPull,
|
[switch]$NoPull,
|
||||||
[array]$PullParams,
|
[array]$PullParams,
|
||||||
[array]$LogsParams,
|
[array]$LogsParams,
|
||||||
[array]$UpParams=@('-d','--remove-orphans'),
|
[array]$UpParams=@('--detach','--remove-orphans'),
|
||||||
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
||||||
[array]$Containers
|
[array]$Containers
|
||||||
)
|
)
|
||||||
|
@ -44,6 +44,8 @@ if( -not $LogsParams[0] ) {
|
||||||
$logsParams[0] += @("--tail=$tailLen")
|
$logsParams[0] += @("--tail=$tailLen")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$local:moreParams = @()
|
||||||
|
#if( $ForceNoFollow ) { $moreParams = @('--no-color', '--quiet-pull') }
|
||||||
$PullParams[0] = @('pull' ) + $PullParams[0] + $Containers
|
$PullParams[0] = @('pull' ) + $PullParams[0] + $Containers
|
||||||
if( $ForceNoFollow ) { $PullParams[0] = @('&') + $PullParams[0] }
|
if( $ForceNoFollow ) { $PullParams[0] = @('&') + $PullParams[0] }
|
||||||
$UpParams[0] = @('up' ) + $UpParams[0] + $Containers
|
$UpParams[0] = @('up' ) + $UpParams[0] + $Containers
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# 1 - Use native build, which is the default for docker compose
|
||||||
|
# Setting this supresses the following line, which would otherwise be displayed:
|
||||||
|
#### Building with native build. Learn about native build in
|
||||||
|
#### Compose here: https://docs.docker.com/go/compose-native-build/
|
||||||
|
$env:COMPOSE_DOCKER_CLI_BUILD=1
|
Loading…
Reference in New Issue