Giter VIP home page Giter VIP logo

zsh-notify's Introduction

zsh-notify

Desktop notifications for long running commands in ZSH.

Supported terminals and requirements

  • On Mac OS X: Terminal.app or iTerm2;
  • On Linux (and possibly other systems): any terminal application should be supported as xdotool and wmctrl are used to query and modify windows state.

When using the default notifier notifications are posted using terminal-notifier.app on Mac OS X and notify-send on other systems.

When using Tmux on Yosemite, reattach-to-user-namespace is required to prevent terminal-notifier to hang (see julienXX/terminal-notifier#115 for details).

Usage

Just source notify.plugin.zsh.

Configuration

Use zstyle in your ~/.zshrc.

  • Set a custom title for error and success notifications, when using the built-in notifier.

      zstyle ':notify:*' error-title "Command failed"
      zstyle ':notify:*' success-title "Command finished"
    

    The string #{time_elapsed} will be replaced with the command run time.

      zstyle ':notify:*' error-title "Command failed (in #{time_elapsed} seconds)"
      zstyle ':notify:*' success-title "Command finished (in #{time_elapsed} seconds)"
    
  • Change the notifications icons for failure or success. Any image path or URL (Mac OS only) should work.

      zstyle ':notify:*' error-icon "/path/to/error-icon.png"
      zstyle ':notify:*' success-icon "/path/to/success-icon.png"
    

    Try this. Wow.

  • Set a sound for error and success notifications, when using the built-in notifier. On Linux you should specify the path to an audio file.

      zstyle ':notify:*' error-sound "Glass"
      zstyle ':notify:*' success-sound "default"
    
  • Have the terminal come back to front when the notification is posted.

      zstyle ':notify:*' activate-terminal yes
    
  • Disable setting the urgency hint for the terminal when the notification is posted (Linux only).

      zstyle ':notify:*' disable-urgent yes
    
  • Set a different timeout for notifications for successful commands (notifications for failed commands are always posted).

      zstyle ':notify:*' command-complete-timeout 15
    
  • Replace the built-in notifier with a custom one at ~/bin/my-notifier. The custom notifier will receive the notification type (error or success) as the first argument, the time elapsed as the second argument, and the command line as standard input.

      zstyle ':notify:*' notifier ~/bin/my-notifier
    
  • Disable error reporting (or send it somewhere else)

      zstyle ':notify:*' error-log /dev/null
    

Installation

Add antigen bundle marzocchi/zsh-notify to your .zshrc with your other bundle commands.

Antigen will handle cloning the plugin for you automatically the next time you start zsh. You can also add the plugin to a running zsh with antigen bundle marzocchi/zsh-notify for testing before adding it to your .zshrc.

  1. git clone [email protected]:marzocchi/zsh-notify.git ~/.oh-my-zsh/custom/plugins/notify
  2. Add zsh-notify to your plugin list - edit ~./zshrc and change plugins=(...) to plugins=(... notify)

Note: when cloning, specify the target directory as notify since Oh-My-Zsh expects the plugin's initialization file to have the same name as it's directory.

Add zgen load marzocchi/zsh-notify to your .zshrc file in the same function you're doing your other zgen load calls in.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.