Ask Your Question
0

Enable terminal notification in zsh

asked 2017-12-04 11:17:10 -0500

SettembreNero gravatar image

Hi, I'm using zsh+oh-my-zsh, but unfortunately the end job notification (like in Bash) is not working. Does anybody know how to enable them again?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-21 17:51:40 -0500

hedayat gravatar image

Add the following in your ~/.zshrc file:

zsh__vte_prompt_command () {
        local command=$(HISTTIMEFORMAT= fc -l -1 | sed 's/^ *[0-9]\+ *//')
        command="${command//;/ }"
        local pwd='~'
        [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
        printf "\033]777;notify;Command completed;%s\007\033]0;%s@%s:%s\007%s" "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
}

precmd () {
    if which __vte_prompt_command &> /dev/null; then
            zsh__vte_prompt_command
    fi
}

Note: if it already contains a precmd() function, add these 3 lines in that function. or you might use precmd_functions approach which I don't describe but is easy to find...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-04 11:17:10 -0500

Seen: 109 times

Last updated: Feb 21