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:
lksz 2021-02-18 10:53:32 -05:00
parent f947b0b3b4
commit f7df96c55d
7 changed files with 127 additions and 78 deletions

14
base.linux/Get-Mount.ps1 Normal file
View File

@ -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 = $_
})
}

View File

@ -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" ) ) {

View File

@ -1,25 +1,38 @@
[CmdletBinding()]param([string]$Path)
[CmdletBinding()]param(
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,Position=0)]
[Alias("FullName")]
[string[]]$Path
)
process {
function Get-FullPath {
param([string]$Path)
function Get-FullPath {
param([string]$Path)
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($Path)){
[System.IO.Path]::GetFullPath($Path)
}else{
[System.IO.Path]::GetFullPath((Join-Path $PWD $Path))
}
}
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($p)){
[System.IO.Path]::GetFullPath($p)
}else{
[System.IO.Path]::GetFullPath((Join-Path $PWD $p))
}
}
}
if( $Path[0] -eq '@' ) {
$Path = Join-Path $MyPSScriptRoot $Path.Substring(1)
}
if([System.IO.Path]::IsPathRooted($Path)){
[System.IO.Path]::GetFullPath($Path)
}else{
[System.IO.Path]::GetFullPath((Join-Path $PWD $Path))
}
# try {
# get-item $Path -Force -ErrorAction Stop |
# Select-Object -ExpandProperty FullName

View File

@ -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

View File

@ -1,56 +1,64 @@
{
"neovim": [
"~/.config/nvim/init.vim",
"~/.config/nvim/vim-plug/plugins.vim",
"#vim",
"#vi"
],
"vi": "~/.virc",
"zshrc": "~/.zshrc",
"shrc": "~/.shrc",
"sz-aliases-sh": "~/.sz.aliases.sh",
"sz-shrc": [
"~/.sz.shrc.sh",
"#shrc",
"@shell-loading-snippets/bash",
"@shell-loading-snippets/sh"
],
"sz-zshrc": [
"~/.sz.zshrc.sh",
"#zshrc",
"@shell-loading-snippets/zsh"
],
"sz-rc-all": [
"#sz-aliases-sh",
"#sz-local-rc",
"#sz-shrc",
"#sz-zshrc",
"#zshrc"
],
"sz-local-rc": "~/.sz.local.sh",
"ansible": [
"/etc/ansible/ansible.cfg",
"/opt/ansible/ansible.cfg",
"/opt/ansible/hosts"
],
"vim": [
"~/.vimrc",
"~/.vim/vimrc"
],
"nvim": [
"~/.config/nvim/init.vim",
"~/.nvimrc",
"#vim"
],
"tmux": [
"~/.tmux.conf",
"~/.byobu/.tmux.conf"
],
"ssh-pub": "~/.ssh/id_*.pub",
"ssh-id": ["~/.ssh/id_ed25519","~/.ssh/id_rsa"],
"ssh-auth": "~/.ssh/authorized_keys",
"ssh-known": "~/.ssh/known_hosts",
"ssh-conf": "~/.ssh/config",
"sshd-conf": "/etc/ssh/sshd_config",
"ssh" : [ "#ssh-auth", "#ssh-known", "#ssh-conf", "#sshd-conf", "#ssh-pub", "#ssh-id" ]
"neovim": [
"~/.config/nvim/init.vim",
"~/.config/nvim/vim-plug/plugins.vim",
"#vim",
"#vi"
],
"vi": "~/.virc",
"zshrc": "~/.zshrc",
"shrc": "~/.shrc",
"sz-aliases-sh": "~/.sz.aliases.sh",
"sz-shrc": [
"~/.sz.shrc.sh",
"#shrc",
"@shell-loading-snippets/bash",
"@shell-loading-snippets/sh"
],
"sz-zshrc": [
"~/.sz.zshrc.sh",
"#zshrc",
"@shell-loading-snippets/zsh"
],
"sz-rc-all": [
"#sz-aliases-sh",
"#sz-local-rc",
"#sz-shrc",
"#sz-zshrc",
"#zshrc"
],
"sz-local-rc": "~/.sz.local.sh",
"ansible": [
"/etc/ansible/ansible.cfg",
"/opt/ansible/ansible.cfg",
"/opt/ansible/hosts"
],
"emacs": [
"~/.emacs",
"~/.emacs.d"
],
"spacemacs": [
"~/.spacemacs",
"#emacs"
],
"vim": [
"~/.vimrc",
"~/.vim/vimrc"
],
"nvim": [
"~/.config/nvim/init.vim",
"~/.nvimrc",
"#vim"
],
"tmux": [
"~/.tmux.conf",
"~/.byobu/.tmux.conf"
],
"ssh-pub": "~/.ssh/id_*.pub",
"ssh-id": ["~/.ssh/id_ed25519","~/.ssh/id_rsa"],
"ssh-auth": "~/.ssh/authorized_keys",
"ssh-known": "~/.ssh/known_hosts",
"ssh-conf": "~/.ssh/config",
"sshd-conf": "/etc/ssh/sshd_config",
"ssh" : [ "#ssh-auth", "#ssh-known", "#ssh-conf", "#sshd-conf", "#ssh-pub", "#ssh-id" ]
}

View File

@ -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

5
docker/profile.d/env.ps1 Normal file
View File

@ -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