Created
December 8, 2015 17:13
-
-
Save doostinharrell/1b100ed9bea5ddcfb6c7 to your computer and use it in GitHub Desktop.
Receive completion notifications for long running commands.
This file contains hidden or 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
# This file should be placed in ~/.config/fish/functions/fish_notify.fish | |
function fish_right_prompt | |
if test $CMD_DURATION | |
# Store duration of last command | |
set duration (echo "$CMD_DURATION 1000" | awk '{printf "%.3fs", $1 / $2}') | |
# OS X notification when a command takes longer than notify_duration | |
set notify_duration 10000 | |
set exclude_cmd "zsh|bash|less|man|more|ssh|drush php" | |
if begin | |
test $CMD_DURATION -gt $notify_duration | |
and echo $history[1] | grep -vqE "^($exclude_cmd).*" | |
end | |
# Only show the notification if iTerm is not focused | |
echo " | |
tell application \"System Events\" | |
set activeApp to name of first application process whose frontmost is true | |
if \"iTerm\" is not in activeApp then | |
display notification \"Finished in $duration\" with title \"$history[1]\" | |
end if | |
end tell | |
" | osascript | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment