Skip to content

Instantly share code, notes, and snippets.

@JTBrinkmann
Last active January 7, 2019 11:55
Show Gist options
  • Save JTBrinkmann/4806903b6493ff5c830f45654c5bff39 to your computer and use it in GitHub Desktop.
Save JTBrinkmann/4806903b6493ff5c830f45654c5bff39 to your computer and use it in GitHub Desktop.
small bash function to trigger a toast notification under Bash on Windows; e.g. at the end of a long running task
toast() {
powershell.exe -NoProfile -C "if (Get-Module -ListAvailable -Name BurntToast) { toast -t \"$*\" } else { echo 'Please run \`Install-Module -Name BurntToast\` in a Powershell as administrator'; echo \"$*\" }"
}
toast_title_body() {
toast $1\", \"$2
}
longrunning() {
start=`date +%s`
$*
end=`date +%s`
runtime=$((end-start))
if [ $runtime -gt 5 ]; then
toast_title_body "command finished (${runtime}s)" "$*"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment