Compare commits

..

3 Commits

Author SHA1 Message Date
125a509240 Add touch function to create new empty text file 2024-12-13 21:57:16 +00:00
b49371eaa3 Replace default rm alias with rm function
Define rm to work more like Unix/Linux

* Support -r and -f flags also -rf or -fr
* Support specifying multiple paths to remove
2024-12-13 21:56:06 +00:00
d219cd1479 Replace default cd alias with cd function
Define cd to work more like Unix/Linux:

* No path argument changes to the users home directory
* Passing "-" for the path argument changes to the previous directory
2024-12-13 21:55:41 +00:00
2 changed files with 34 additions and 6 deletions

View File

@ -1,5 +1,5 @@
# Remove these aliases to PowerShell builtins which clobber the actaul exes.
Remove-Item alias:curl
Remove-Item alias:wget
Remove-Item alias:cd
# TODO: Remove default abbriviation aliases
# Remove builtin aliases
Remove-Item Alias:curl
Remove-Item Alias:wget
Remove-Item Alias:cd
Remove-Item Alias:rm

View File

@ -13,4 +13,32 @@ function cd {
Set-Location -Path $Path
}
# TODO: Define rm to work with -rf and multiple entries
function rm {
Param (
[Parameter(
Mandatory=$true,
ValueFromRemainingArguments=$true
)][string[]]$Paths,
[switch]$F, [switch]$Force,
[switch]$R, [switch]$Recurse,
[switch]$RF, [switch]$FR
)
$Command = "Remove-Item"
if ($F -or $Force -or $RF -or $FR) {
$Command = "$Command -Force"
}
if ($R -or $Recurse -or $RF -or $FR) {
$Command = "$Command -Recurse"
}
foreach ($Path in $Paths) {
Invoke-Expression -Command "$Command $Path"
}
}
# Add new aliases
function touch {
Param (
[string]$Path
)
New-Item -Type File $Path
}