• Stars
    star
    6,206
  • Rank 6,456 (Top 0.2 %)
  • Language
    Objective-C
  • License
    Other
  • Created over 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Send User Notifications on macOS from the command-line.

terminal-notifier

GitHub release

terminal-notifier is a command-line tool to send macOS User Notifications, which are available on macOS 10.10 and higher.

News

alerter features were merged in terminal-notifier 1.7. This led to some issues and even more issues in the 1.8 release. We decided with ValĆØre Jeantet to rollback this merge.

From now on terminal-notifier won't have the sticky notification feature nor the actions buttons. If you need them please use alerter. I also want to follow semver hence this latest version starts at 2.0.0.

Sticking to two smaller specialized tools will hopefully make them easier to maintain and less error prone.

Caveats

  • It is currently packaged as an application bundle, because NSUserNotification does not work from a ā€˜Foundation toolā€™. radar://11956694

  • If you intend to package terminal-notifier with your app to distribute it on the Mac App Store, please use 1.5.2; version 1.6.0+ uses a private method override, which is not allowed in the App Store Guidelines.

  • If you're using macOS < 10.10 you should use terminal-notifier 1.6.3.

  • If you're looking for sticky notifications or more actions on a notification please use alerter

Download

Prebuilt binaries are available from the releases section.

Or if you want to use this from Ruby, you can install it through RubyGems:

$ [sudo] gem install terminal-notifier

You can also install it via Homebrew:

$ brew install terminal-notifier

Usage

$ ./terminal-notifier.app/Contents/MacOS/terminal-notifier -[message|group|list] [VALUE|ID|ID] [options]

In order to use terminal-notifier, you have to call the binary inside the application bundle.

The Ruby gem, which wraps this tool, does have a bin wrapper. If installed you can simply do:

$ terminal-notifier -[message|group|list] [VALUE|ID|ID] [options]

This will obviously be a bit slower than using the tool without the wrapper.

If you'd like notifications to stay on the screen until dismissed, go to System Preferences -> Notifications -> terminal-notifier and change the style from Banners to Alerts. You cannot do this on a per-notification basis.

Example Uses

Display piped data with a sound:

$ echo 'Piped Message Data!' | terminal-notifier -sound default

Example 1

Use a custom icon:

$ terminal-notifier -title ProjectX -subtitle "new tag detected" -message "Finished" -appIcon http://vjeantet.fr/images/logo.png

Example 3

Open an URL when the notification is clicked:

$ terminal-notifier -title 'šŸ’°' -message 'Check your Apple stock!' -open 'http://finance.yahoo.com/q?s=AAPL'

Example 4

Open an app when the notification is clicked:

$ terminal-notifier -group 'address-book-sync' -title 'Address Book Sync' -subtitle 'Finished' -message 'Imported 42 contacts.' -activate 'com.apple.AddressBook'

Example 5

Options

At a minimum, you must specify either the -message , the -remove, or the -list option.


-message VALUE [required]

The message body of the notification.

If you pipe data into terminal-notifier, you can omit this option, and the piped data will become the message body instead.


-title VALUE

The title of the notification. This defaults to ā€˜Terminalā€™.


-subtitle VALUE

The subtitle of the notification.


-sound NAME

Play the NAME sound when the notification appears. Sound names are listed in /System/Library/Sounds.

Use the special NAME ā€œdefaultā€ for the default notification sound.


-group ID

Specifies the notificationā€™s ā€˜groupā€™. For any ā€˜groupā€™, only one notification will ever be shown, replacing previously posted notifications.

A notification can be explicitly removed with the -remove option (see below).

Example group IDs:

  • The senderā€™s name (to scope the notifications by tool).
  • The senderā€™s process ID (to scope the notifications by a unique process).
  • The current working directory (to scope notifications by project).

-remove ID [required]

Remove a previous notification from the ID ā€˜groupā€™, if one exists.

Use the special ID ā€œALLā€ to remove all messages.


-list ID [required]

Lists details about the specified ā€˜groupā€™ ID.

Use the special ID ā€œALLā€ to list details about all currently active messages.

The output of this command is tab-separated, which makes it easy to parse.


-activate ID

Activate the application specified by ID when the user clicks the notification.

You can find the bundle identifier (CFBundleIdentifier) of an application in its Info.plist file inside the application bundle.

Examples application IDs are:

  • com.apple.Terminal to activate Terminal.app
  • com.apple.Safari to activate Safari.app

-sender ID

Fakes the sender application of the notification. This uses the specified applicationā€™s icon, and will launch it when the notification is clicked.

Using this option fakes the sender application, so that the notification system will launch that application when the notification is clicked. Because of this it is important to note that you cannot combine this with options like -execute and -activate which depend on the sender of the notification to be ā€˜terminal-notifierā€™ to perform its work.

For information on the ID, see the -activate option.


-appIcon PATH

Specify an image PATH to display instead of the application icon.

WARNING: This option is subject to change, since it relies on a private method.


-contentImage PATH

Specify an image PATH to attach inside of the notification.

WARNING: This option is subject to change since it relies on a private method.


-open URL

Open URL when the user clicks the notification. This can be a web or file URL, or any custom URL scheme.


-execute COMMAND

Run the shell command COMMAND when the user clicks the notification.


-ignoreDnD

Ignore Do Not Disturb settings and unconditionally show the notification.

WARNING: This option is subject to change since it relies on a private method.

License

All the works are available under the MIT license. Except for ā€˜Terminal.icnsā€™, which is a copy of Appleā€™s Terminal.app icon and as such is copyright of Apple.

Copyright (C) 2012-2017 Eloy DurĆ”n [email protected], Julien Blanchard [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

clj-slack

Use Slack REST API from Clojure
Clojure
130
star
2

slacker

Erlang Slack REST API wrapper
Erlang
54
star
3

resque-waiting-room

Resque plugin that throttles your jobs
Ruby
34
star
4

dotnet.el

dotnet CLI minor mode for Emacs
Emacs Lisp
29
star
5

ivy-lobsters

Browse lobste.rs stories from emacs with ivy
Emacs Lisp
24
star
6

helm-lobste.rs

An Helm front-end for Lobste.rs
Emacs Lisp
20
star
7

erc-terminal-notifier.el

OSX notifications via the terminal-notifier gem for Emacs ERC.
Emacs Lisp
17
star
8

mocker

Mock an HTTP service
Rust
17
star
9

resque-slack

Post failed Resque jobs notifications in a Slack channel
Ruby
17
star
10

gophsters

Generate a gophermap from lobste.rs recent stories
Rust
14
star
11

Brewery

Graphical interface for homebrew package management in MacRuby
Ruby
13
star
12

GettingStartedWithFSharpAndDotNetCore

Getting Started With F# And .NET Core examples
F#
7
star
13

julienxx.github.com

julienxx.github.com Github page
CSS
6
star
14

GAppsProvisioning

Google Apps Provisioning API v2.0 Ruby client library
Ruby
6
star
15

email-checker

Rust on AWS Lambda example
Rust
4
star
16

dotvim

My .vim
Vim Script
4
star
17

campfire-notifier

Campfire Notifier written in Clojure
Clojure
4
star
18

dotemacs

.emacs.d
Emacs Lisp
4
star
19

Sideburns.eu

My blog
JavaScript
3
star
20

dotfiles

Various dot files
Shell
3
star
21

iShrt.tl

Iphone app for Tigerlily's URL shortener shrt.tl
Objective-C
2
star
22

i3config

Perl
2
star
23

favfetcher

FavIcon fetcher
Clojure
2
star
24

getafe

Getafe Vim Color scheme
Vim Script
2
star
25

elixir_exercices

PragProg Elixir book exercises
Elixir
2
star
26

ChromiumUpdater

Updates Chromium OS X with the latest build
Ruby
2
star
27

fingers

Finger command with Slack as a Backend
Rust
2
star
28

MadRiver

Mad River website
JavaScript
2
star
29

soccer-ocaml

Get soccer results from the command line.
OCaml
2
star
30

ClojureSandbox

My Clojure sandbox
Clojure
2
star
31

rouflaquettes

Twitter favorites to Del.icio.us bookmarks converter
JavaScript
2
star
32

Topfunky.tmTheme

A TextMate theme inspired by @topfunky emacs theme.
2
star
33

Resquell

Do stuff with Resque jobs in Haskell
Haskell
1
star
34

simple-server

A very simple HTTP server.
Rust
1
star
35

vatmess

A simple JSON API to retrieve what VAT rate to apply to an EU customer. #VATMESS
Clojure
1
star
36

yeoman.el

Interact with Yeoman from Emacs.
Emacs Lisp
1
star
37

dlobstergopher

Create a gophermap file from lobste.rs newest entries
D
1
star
38

rust-resque-example

Use Resque from Rust examples.
Rust
1
star
39

gophell

Haskell
1
star
40

clojure-is-love

Slides from my talk at Functional Progammers Paris - Take 1.
JavaScript
1
star