Little shell tips
Friday, 27. June 2008, 20:16:40
(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








How to use Quote function: