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
This commit is contained in:
		
							parent
							
								
									d219cd1479
								
							
						
					
					
						commit
						b49371eaa3
					
				| @ -2,3 +2,4 @@ | |||||||
| Remove-Item Alias:curl | Remove-Item Alias:curl | ||||||
| Remove-Item Alias:wget | Remove-Item Alias:wget | ||||||
| Remove-Item Alias:cd | Remove-Item Alias:cd | ||||||
|  | Remove-Item Alias:rm | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								utils.ps1
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								utils.ps1
									
									
									
									
									
								
							| @ -13,4 +13,24 @@ function cd { | |||||||
|   Set-Location -Path $Path |   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" | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user