Skip navigation.

Arnaud

a blog about English and art (atm)

Little shell tips

Below are some bash tips without any explanation, just read the reference1 for further information.

(for mpc users but one can customize bash completion for other uses)

$ mpc help | awk '$0 !~ /Displays status/ && $0 !~ /Usage/ && $0 !~ /mpc version/ && $0 !~ /For more/  {print $2}' > mpc.words 
$ complete -W "$(cat mpc.words)" mpc
$ mpc [TAB]
add          crossfade    enable       ls           next         play         random       save         shuffle      toggle       
clear        del          listall      lsplaylists  outputs      playlist     repeat       search       stats        update       
crop         disable      load         move         pause        prev         rm           seek         stop         volume       


Many people know C-r for a incremental backwards-search through history. There are other keys combinations like M-p which allows a non-incremental search for a string.
M-p, type a string then press Return and it will fill with a match.

$ cat > hostfile
google.fr
opera.com   
jamendo.com
$ export HOSTFILE=hostfile
$ @ [TAB]
@localhost  @localhost.localdomain  @google.fr  @jamendo.com @opera.com
$ complete -W "$(cat $HOSTFILE)" ping
$ ping [TAB]
google.fr    jamendo.com  opera.com    



---
1: $ man bash

MyOpera friendshipBack from Switzerland

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

November 2009
M T W T F S S
October 2009December 2009
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30