aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_config_interactive.fish
diff options
context:
space:
mode:
authorGravatar Ben Liblit <liblit@cs.wisc.edu>2015-05-28 03:10:56 -0500
committerGravatar Ben Liblit <liblit@cs.wisc.edu>2015-05-28 03:10:56 -0500
commit5c4acc8ee1485e40b00ea0578aeff338078cfb8b (patch)
tree615abee2f94239d9500e561e49ef3656545f2895 /share/functions/__fish_config_interactive.fish
parent92a9ba478babc0e2c0bfbc7dab319f8c946d65fe (diff)
Notify vte-based terminals when a command completes.
Notification is sent using an OSC 777 escape sequence as described at http://known.phyks.me/2014/local-notifications-for-weechat-and-urxvt. The specific notification is crafted to match that emitted by bash when running under Fedora 22 with the "vte-profile" RPM installed. See the code for "__vte_prompt_command" starting at http://pkgs.fedoraproject.org/cgit/vte291.git/tree/vte291-command-notify.patch#n307 to see exactly what bash produces. My approach is, however, a bit more paranoid about control characters embedded in commands. Gnome-terminal 3.16 responds to this escape sequence by posting a desktop notification if the containing terminal window does not have focus. This lets the user know that a long-running background command has completed. Job notification is promoted as a Fedora 22 feature (http://fedoramagazine.org/terminal-job-notifications-in-fedora-22-workstation/), so it would be good for fish users to be benefit from it. Conversely, anyone who does not want this feature can use "functions --erase __notify_vte_command_completed" to turn it off.
Diffstat (limited to 'share/functions/__fish_config_interactive.fish')
-rw-r--r--share/functions/__fish_config_interactive.fish10
1 files changed, 10 insertions, 0 deletions
diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish
index 9b27fb98..1551b305 100644
--- a/share/functions/__fish_config_interactive.fish
+++ b/share/functions/__fish_config_interactive.fish
@@ -196,6 +196,16 @@ function __fish_config_interactive -d "Initializations that should be performed
end
end
+ # Notify vte-based terminals when a command completes
+ if test "$VTE_VERSION" -ge 3405
+ switch "$TERM"
+ case 'vte*' 'xterm*'
+ function __notify_vte_command_completed --on-event fish_postexec --description 'Notify VTE of command completion'
+ printf '\e]777;notify;Command completed;%s\a' (echo "$argv" | cat --show-nonprinting | tr --delete \;)
+ end
+ end
+ end
+
# The first time a command is not found, look for command-not-found
# This is not cheap so we try to avoid doing it during startup
# config.fish already installed a handler for noninteractive command-not-found,