Last active
August 5, 2024 18:24
-
-
Save espaciomore/28e24ce4f91177c0964f4f67bb5c5fda to your computer and use it in GitHub Desktop.
Watch command for Git Bash
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
#!/bin/bash | |
ARGS="${@}" | |
clear; | |
while(true); do | |
OUTPUT=`$ARGS` | |
clear | |
echo -e "${OUTPUT[@]}" | |
done |
you can add it as a function to ~/.bash_aliases
watch () {
ARGS="${@}"
clear;
while(true); do
clear
OUTPUT=`$ARGS`
echo -e "${OUTPUT[@]}"
sleep 1
done
}
And I added some additional information to the watch function to make it look like it does in native linux -
watch () {
ARGS="${@}"
clear;
while(true); do
OUTPUT=`$ARGS`
clear
echo -e "Every 1.0s: $ARGS"
echo ""
echo -e "${OUTPUT[@]}"
sleep 1
done
}
And I added some additional information to the watch function to make it look like it does in native linux -
watch () { ARGS="${@}" clear; while(true); do OUTPUT=`$ARGS` clear echo -e "Every 1.0s: $ARGS" echo "" echo -e "${OUTPUT[@]}" sleep 1 done }
this is awesome!!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mingw64 does not have watch so I found this gist. I tried to look at the esacpe sequence of original watch with strace with
strace -f watch echo test
. Found this escape sequence:write(1, "\33[1;75H", 7�[1;75H) = 7