Skip to content

Instantly share code, notes, and snippets.

@espaciomore
Last active February 27, 2024 20:49
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save espaciomore/28e24ce4f91177c0964f4f67bb5c5fda to your computer and use it in GitHub Desktop.
Save espaciomore/28e24ce4f91177c0964f4f67bb5c5fda to your computer and use it in GitHub Desktop.
Watch command for Git Bash
#!/bin/bash
ARGS="${@}"
clear;
while(true); do
OUTPUT=`$ARGS`
clear
echo -e "${OUTPUT[@]}"
done
@FarisHijazi
Copy link

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
}

@sturdy5
Copy link

sturdy5 commented May 21, 2023

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment