add an "alert" alias, which can optionally be added after long running commands

Bug #616028 reported by Dustin Kirkland 
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Fix Released
Wishlist
Dustin Kirkland 

Bug Description

Binary package hint: bash

This bug is closely related, though slightly different from Bug #315932.

I recently posted:
http://blog.dustinkirkland.com/2010/07/dear-command-line-please-ping-me-when.html

This post received some positive feedback in the comments and in IRC. A number of people have asked for this sort of functionality in the default Ubuntu .bashrc. I think this is a perfectly reasonable request. It doesn't get in the way, as current users must consciously append "; alert" onto their long running commands.

We can experiment with this as a proof-of-concept in Maverick, and perhaps look at better ways of doing this automagically by default (again, see the really interesting implementation in Bug #315932).

I have tested:
 a) when libnotify-bin is not installed -- command-not-found prints a useful error message
 b) when gnome-terminal is not installed -- icons aren't present; notify message pops up without icons; still functional
 c) over ssh -X -- works fine, assuming the client and host has the necessary packages to do libnotify stuff

Changed in bash (Ubuntu):
status: New → In Progress
assignee: nobody → Dustin Kirkland (kirkland)
importance: Undecided → Wishlist
Revision history for this message
Paul Sladen (sladen) wrote :

For the moment, commited as:

  alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

with generic icon 'terminal' so that it should be happier on K/Xubuntu with reduced icons sets and the lower priority to not be unnecessarily noisy. Long-term there are going to be better solutions(tm).

Changed in bash (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bash - 4.1-2ubuntu4

---------------
bash (4.1-2ubuntu4) maverick; urgency=low

  * debian/skel.bashrc: add 'alert' alias, LP: #616028
 -- Dustin Kirkland <email address hidden> Tue, 10 Aug 2010 15:35:08 -0400

Changed in bash (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
stenzn (stenzn) wrote :

The default .bashrc should also have a comment added stating that the user has to install libnotify-bin, which is not installed by default in Maverick, to get the notify-send binary; otherwise the pop-up notification won't work.

Having libnotify-bin in the default install would take care of it too, but notify-send doesn't seem to be looked upon too highly by the folks in charge of notifications in Ubuntu anyway.

Revision history for this message
Dustin Kirkland  (kirkland) wrote : Re: [Bug 616028] Re: add an "alert" alias, which can optionally be added after long running commands

The first time you try to use 'alert', command-not-found tells you
that you need to install libnotify-bin, right?

Revision history for this message
yp (pir-yur) wrote :

I definitely agree with nstenz that a comment specifying the 'libnotify-bin' pre-requisite. In my opinion, having such an alias and discovering that it does not work out-of-the-box after the long command has been completed without notification is annoying.

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Martin,

Do you think we could add libnotify-bin to the ubuntu desktop seeds, such that we have the notify-send command available for the "alert" alias, which is in the bash profile now?

Dustin

Revision history for this message
Martin Pitt (pitti) wrote :
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Awesome, thanks, Martin!

Revision history for this message
Guy Van Sanden (gvs) wrote :

I was pointed here by a commenter on my blog, I've just written something similar but using Jabber for notifications to make it work on a number of servers instead of my desktop alone.

Revision history for this message
Guy Van Sanden (gvs) wrote :
Revision history for this message
Akbarkhon Variskhanov (kbar) wrote :

Separating the first part of a list and the `alert` part with && (or any of the doubled control operators) will result the second character to be printed in the body of the message. Adding the asterisk after the [;&|] bracket expression fixes it.

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]*\s*alert$//'\'')"'

Bug #1953151

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.