Powershell time command

March 10, 2022powershell

I commbined the best parts of this StackOverflow answer and this Super User answer to come up with this solution for a time function in Powershell:

function time {
    $Command = "$args";
    (Measure-Command { Invoke-Expression $Command 2>&1 | Out-Default }).ToString();
}

Example usage:

# time git pull
00:00:01.0804938

Windows Terminal fork command

I wanted a way to fork the current tab in Windows Terminal and so I've come up with this PowerShell function:

function fork { wt -w 0 -d "$(Get-Location)" }