Last active
October 21, 2016 15:13
-
-
Save bender-the-greatest/2dce08866ce176426fdc41d021a4c4bf to your computer and use it in GitHub Desktop.
Rudimentary implementation of *nix watch command for Powershell
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
# Rudimentary implementation of *nix watch command for Powershell | |
# Tested under 2.0 and 5.1 | |
# Example usage: | |
# watch ls | |
# watch 'echo "Command with parameters"' | |
# watch -n 1 'echo "Display this every second"' | |
# watch -n 1 -command 'echo "Explicit use of the command parameter"' | |
function watch { | |
Param( | |
[Parameter(Mandatory=$true)][string] | |
$command, | |
[Parameter(Mandatory=$false)][int] | |
$n = 2 | |
) | |
while($true) { | |
clear | |
Write-Output (iex $command | Format-Table) | |
sleep $n | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment