Compare commits
2 Commits
125a509240
...
fc57d48814
Author | SHA1 | Date | |
---|---|---|---|
fc57d48814 | |||
5ec851fe11 |
@ -2,3 +2,4 @@
|
||||
Remove-Item Alias:curl
|
||||
Remove-Item Alias:wget
|
||||
Remove-Item Alias:cd
|
||||
Remove-Item Alias:rm
|
||||
|
33
utils.ps1
33
utils.ps1
@ -13,4 +13,35 @@ function cd {
|
||||
Set-Location -Path $Path
|
||||
}
|
||||
|
||||
# TODO: Define rm to work with -rf and multiple entries
|
||||
# Define rm to work like Unix/Linux
|
||||
# * Support -r and -f flags also -rf or -fr
|
||||
# * Support specifying multiple paths to remove
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
# Define touch to create a new empty text file
|
||||
function touch {
|
||||
Param (
|
||||
[string]$Path
|
||||
)
|
||||
New-Item -Type File $Path
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user