Created
January 18, 2017 17:12
-
-
Save Xainey/bc4e497435b440f6699a4f778c89a0c5 to your computer and use it in GitHub Desktop.
Touch command for PowerShell $Profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add nix-like touch command | |
function touch | |
{ | |
$file = $args[0] | |
if($file -eq $null) | |
{ | |
throw "No filename supplied" | |
} | |
if(Test-Path $file) | |
{ | |
(Get-ChildItem $file).LastWriteTime = Get-Date | |
} | |
else | |
{ | |
# UTF-16 LE | |
# echo $null > $file | |
# UTF-8 With BOM | |
# $null | Out-File $file -Encoding "UTF8" | |
# UTF-8 W/O BOM | |
[IO.File]::WriteAllLines("$pwd\$file", "") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment