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 {
|
||||
if ($Path -match '\*|\?|~') {
|
||||
Get-ChildItem -Path $_ | Select-Object -ExpandProperty FullName
|
||||
} else { $_ }
|
||||
} ) -join "' '"
|
||||
$local:arguments = $Path | Get-Path | Join-String -Separator "' '"
|
||||
if( $Path ) { $arguments = "'$arguments'" }
|
||||
|
||||
if( $PSCmdlet.ShouldProcess( "Edit ($editor): $arguments" ) ) {
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
[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)
|
||||
|
||||
if([System.IO.Path]::IsPathRooted($Path)){
|
||||
|
@ -8,18 +13,26 @@ function Get-FullPath {
|
|||
}else{
|
||||
[System.IO.Path]::GetFullPath((Join-Path $PWD $Path))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $Path[0] -eq '@' ) {
|
||||
$Path = Join-Path $MyPSScriptRoot $Path.Substring(1)
|
||||
}
|
||||
foreach( $local:p in $Path ) {
|
||||
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)){
|
||||
[System.IO.Path]::GetFullPath($Path)
|
||||
}else{
|
||||
[System.IO.Path]::GetFullPath((Join-Path $PWD $Path))
|
||||
if([System.IO.Path]::IsPathRooted($p)){
|
||||
[System.IO.Path]::GetFullPath($p)
|
||||
}else{
|
||||
[System.IO.Path]::GetFullPath((Join-Path $PWD $p))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# try {
|
||||
# get-item $Path -Force -ErrorAction Stop |
|
||||
# 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/hosts"
|
||||
],
|
||||
"emacs": [
|
||||
"~/.emacs",
|
||||
"~/.emacs.d"
|
||||
],
|
||||
"spacemacs": [
|
||||
"~/.spacemacs",
|
||||
"#emacs"
|
||||
],
|
||||
"vim": [
|
||||
"~/.vimrc",
|
||||
"~/.vim/vimrc"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
[switch]$NoPull,
|
||||
[array]$PullParams,
|
||||
[array]$LogsParams,
|
||||
[array]$UpParams=@('-d','--remove-orphans'),
|
||||
[array]$UpParams=@('--detach','--remove-orphans'),
|
||||
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
||||
[array]$Containers
|
||||
)
|
||||
|
@ -44,6 +44,8 @@ if( -not $LogsParams[0] ) {
|
|||
$logsParams[0] += @("--tail=$tailLen")
|
||||
}
|
||||
|
||||
$local:moreParams = @()
|
||||
#if( $ForceNoFollow ) { $moreParams = @('--no-color', '--quiet-pull') }
|
||||
$PullParams[0] = @('pull' ) + $PullParams[0] + $Containers
|
||||
if( $ForceNoFollow ) { $PullParams[0] = @('&') + $PullParams[0] }
|
||||
$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