From a6cc9cf8b558818522871e940829f50be23cf828 Mon Sep 17 00:00:00 2001 From: Nulo Date: Fri, 14 Jan 2022 23:08:50 -0300 Subject: [PATCH] bash: OSC 777 --- .bashrc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.bashrc b/.bashrc index 1b4c3e9..b16f170 100644 --- a/.bashrc +++ b/.bashrc @@ -49,3 +49,24 @@ if ! "$REMOTE"; then export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" fi fi + +# ------------------------------------------------------------------------------ +# Notifications through OSC 777 +# Based on https://github.com/t413/zsh-background-notify/blob/master/bgnotify.plugin.zsh + +last_command () { + history 1 | cut -c 8- +} + +notify () { ## args: (title, subtitle) + echo -ne "\033]777;notify;[$(hostname)] $1;$2\a" +} +notify_command () { + if test $? -eq 0; then + notify "success" "$(last_command)" + else + notify "fail" "$(last_command)" + fi +} + +PROMPT_COMMAND="notify_command;$PROMPT_COMMAND"