Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged notify-send from sorted by
Terminal - Commands tagged notify-send - 14 results
notify-send -t 5000 "date" "$(date)"
2013-08-27 03:15:14
User: qcjn
Tags: notify-send
3

you can put almost any command.

notify-send -t 0 "MOTD" "$(sed -n '/#^4/,/#$4/{/#^4\|#$4/!p}' motd2 | cut -d# -f2)" notify-send -t 0 "readfile" "$(while read mess; do echo $mess;done < motd2)"
r="readlink /proc/`pgrep -o mplayer`/fd/3";while [ -e "`$r`" ];do if [ "$f" = "`$r`" ];then sleep 1;else f="`$r`";notify-send " $f";fi;done
2012-02-26 06:49:16
User: aix
Functions: sleep
0

Will finish automagically when mplayer quits. Can be run from any directory.

It seems to finish by it self rarely, probably because of some timing issue? There's probably a way around that which I can't think of right now

tail -n0 -f /var/log/messages | while read line; do notify-send "System Message" "$line"; done
2011-07-11 22:33:24
User: hukketto
Functions: read tail
Tags: notify-send
1

It willl popup a message for each new entry in /var/log/messages

found on the notify-send howto page on ubuntuforums.org.

Posted here only because it is one of the favourites of mine.

while notify-send "`acpi -t`"; do sleep 300; done
2011-07-05 18:22:06
Functions: sleep
1

Use acpi and notify-send to report current temperature every five minutes.

Works best in a shell script run at startup. acpi is called for temperature and fed to notify-send for a tooltip. After waiting five minutes, it will start over.

while ping -c 1 127.0.0.1 > /dev/null; do acpi -t -f | while read tem; do notify-send "$tem"; done; sleep 300; done
2011-07-02 06:47:25
User: c0de
Functions: acpi ping read sleep
2

works best in a shell script run at startup. It will ping localhost once and output to null, after it does that, acpi is called for temperature in fahrenheit and piped through to another loop that feeds notify-send for a tooltip. After waiting five minutes, it will start over.

watch -n 900 "notify-send -t 10000 'Look away. Rest your eyes'"
2010-10-05 09:39:31
User: b_t
Functions: watch
0

Note:

1) -n option of watch accepts seconds

2) -t option of notify-send accepts milliseconds

3) All quotes stated in the given example are required if notification

message is more than a word.

4) I couldn't get this to run in background (use of & at the end fails). Any

suggestions/improvements welcome.

alias alert='notify-send -i /usr/share/icons/gnome/32x32/apps/gnome-terminal.png "[$?] $(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/;\s*alert$//'\'')"'
2010-09-12 02:54:40
User: pkiller
Functions: alias
10

This is an alias you can add to your .bashrc file to get notified when a job you run in a terminal is done.

example of use

sleep 20; alert

Source:http://www.webupd8.org/2010/07/get-notified-when-job-you-run-in.html

echo notify-send test | at now+1minute
2010-08-08 03:11:11
User: polar
Functions: at echo test
Tags: notify-send
4

The simplest way to do it.

Works for me, at least. (Why are the variables being set?)

DISPLAY=:0.0 XAUTHORITY=~/.Xauthority notify-send test
2010-08-03 01:17:02
User: aurium
Tags: notify-send
11

we don't need to export variables to set a env to a command, we may do this before the command directly

echo "export DISPLAY=:0; export XAUTHORITY=~/.Xauthority; notify-send test" | at now+1minute
2010-07-27 00:10:08
Functions: at echo
Tags: notify-send
20

You can write a script that does this :

remind <minutes> [<message>]
sleep 6s && notify-send -t 10000 -u critical "remember to think" &
2010-07-01 02:17:24
User: zed
Functions: sleep
5

This will be seen through your system's visual notification system, notify-osd, notification-daemon, etc.

---

sleep accepts s,m,h,d and floats (date; sleep .25m; date)

---

notify-send (-t is in milliseconds && -u low / normal / critical)

man notify-send for more information

---

notification-daemon can use b/i/u/a HTML

echo 'Desktop SPAM!!!' | while read SPAM_OUT; do notify-send "$SPAM_OUT"; done
2009-12-31 15:38:35
User: michelsberg
Functions: echo read
Tags: notify-send
2

Route output to notify-send to show nice messages on the desktop, e.g. title and interpreter of the current radio stream

./my-really-long-job.sh && notify-send "Job finished"
2009-05-07 15:50:27
User: root
Tags: notify-send
24

You will need libnotify-bin for this to work:

sudo aptitude install libnotify-bin
notify-send ["<title>"] "<body>"
2009-04-29 10:05:20
User: cammarin
45

The title is optional.

Options:

-t: expire time in milliseconds.

-u: urgency (low, normal, critical).

-i: icon path.

On Debian-based systems you may need to install the 'libnotify-bin' package.

Useful to advise when a wget download or a simulation ends. Example:

wget URL ; notify-send "Done"