Last active
May 29, 2025 03:14
-
-
Save delphinus/d1280fd9c9f32218f2c65477ec3640db to your computer and use it in GitHub Desktop.
Notify when slow commands finished in background
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
set -gx NOTIFY_ON_COMMAND_DURATION 5000 | |
function fish_right_prompt | |
if test -n "$CMD_DURATION"; and test $CMD_DURATION -gt $NOTIFY_ON_COMMAND_DURATION | |
if type -q wezterm; and test -n "$WEZTERM_PANE" | |
set -l active_pid (osascript -e 'tell application "System Events" to get the unix id of first process whose frontmost is true') | |
set -l active_pane (wezterm cli list-clients --format json | /usr/bin/ruby -r json -e 'puts JSON.parse($<.read).find{|x|x["pid"]=='$active_pid'}["focused_pane_id"]') | |
if test -n "$active_pane"; and test $WEZTERM_PANE -eq $active_pane | |
return | |
end | |
end | |
set -l duration (bc -S2 -e $CMD_DURATION/1000) | |
set -l msg (echo (history | head -1) returned $status after $duration s) | |
osascript -e 'display notification "'$msg'" with title "command completed"' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WezTerm + fish でコマンドが完了したら通知する #macOS - Qiita