mirror of
				https://github.com/ohmyzsh/ohmyzsh.git
				synced 2025-11-04 21:31:19 +08:00 
			
		
		
		
	bgnotify zsh plugin
cross-platform background notifications for long running commands! Supports OSX and Linux.
Standalone homepage: t413/zsh-background-notify
How to use
Just add bgnotify to your plugins list in your .zshrc
- On OS X you'll need terminal-notifier
brew install terminal-notifier(orgem install terminal-notifier)
 - On Linux, make sure you have 
notify-sendorkdialoginstalled. If you're using Ubuntu you should already be all set! - On Windows you can use notifu or the Cygwin Ports libnotify package
 
Screenshots
Linux
OS X
Windows
Configuration
One can configure a few things:
bgnotify_bellenabled or disables the terminal bell (default true)bgnotify_thresholdsets the notification threshold time (default 6 seconds)function bgnotify_formattedlets you change the notification. You can for instance customize the message and pass in an icon.bgnotify_extraargsappends extra args to notifier (e.g.-efor notify-send to create a transient notification)
Use these by adding a function definition before the your call to source. Example:
bgnotify_bell=false   ## disable terminal bell
bgnotify_threshold=4  ## set your own notification threshold
function bgnotify_formatted {
  ## $1=exit_status, $2=command, $3=elapsed_time
  # Humanly readable elapsed time
  local elapsed="$(( $3 % 60 ))s"
  (( $3 < 60 ))   || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
  (( $3 < 3600 )) || elapsed="$((  $3 / 3600 ))h $elapsed"
  [ $1 -eq 0 ] && title="Holy Smokes Batman" || title="Holy Graf Zeppelin"
  [ $1 -eq 0 ] && icon="$HOME/icons/success.png" || icon="$HOME/icons/fail.png"
  bgnotify "$title - took ${elapsed}" "$2" "$icon"
}
plugins=(git bgnotify)  ## add to plugins list
source $ZSH/oh-my-zsh.sh  ## existing source call
			
		

