Skip to content

Instantly share code, notes, and snippets.

@Xainey
Created January 18, 2017 17:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xainey/bc4e497435b440f6699a4f778c89a0c5 to your computer and use it in GitHub Desktop.
Save Xainey/bc4e497435b440f6699a4f778c89a0c5 to your computer and use it in GitHub Desktop.
Touch command for PowerShell $Profile
# 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