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

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