Inserts the results of an autocompletion in the command line

Pressing ESC then * will insert in the command line the results of the autocompletion. It's hard to explain but if you look the sample output or do echo ESC * you will understand quickly. By the way, few reminders about ESC : - Hold ESC does the same thing as tab tab - 'ESC .' inserts the last argument of last command (can be done many times in order to get the last argument of all previous commands)
Sample Output
$ echo <ESC><*>
$ echo aaa aab aba abb baa bab bba bbb

$ echo a<ESC><*>
$ echo aaa aab aba abb
but also :

$ <ESC><*>
$ \: \! . .. ... .... \[ \[\[ ]] \{ } 4xml 4xpath 4xslt 4xupdate 822-date 915resolution _a2dismod _a2dissite _a2enmod _a2ensite a2p a2ping aa-audit aa-autodep aa-complain aa-enforce aa-genprof aa-logprof aa-status aa-unconfined accept accessdb aconnect acpi acpi_available acpid acpi_fakekey acpi_listen acroread acyclic

(I stopped but it's basically the list of all the commands).

By: Josay
2009-06-14 21:17:40

These Might Interest You

  • Similar output to using MySQL with the \G at the end of a Query. Displays one column per line. Other modes include: -column Query results will be displayed in a table like form, using whitespace characters to separate the columns and align the output. -html Query results will be output as simple HTML tables. -line Query results will be displayed with one value per line, rows separated by a blank line. Designed to be easily parsed by scripts or other programs -list Query results will be displayed with the separator (|, by default) character between each field value. The default. From inside the command line this can be also changed using the mode command: .mode MODE ?TABLE? Set output mode where MODE is one of: csv Comma-separated values column Left-aligned columns. (See .width) html HTML code insert SQL insert statements for TABLE line One value per line list Values delimited by .separator string tabs Tab-separated values tcl TCL list elements Show Sample Output

    sqlite3 -line database.db
    pykler · 2010-10-09 16:10:19 0
  • You can, of course, tell MySQL to output results to a file and dictate how to terminate lines, etc. But sometimes you don't have access to the file system MySQL is running on, complicating outputting your results to a CSV, necessitating either annoying hacks or this simple command :D

    mysql -umysqlusername -pmysqlpass databsename -B -e "select * from \`tabalename\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > mysql_exported_table.csv
    awjrichards · 2011-05-26 19:01:55 0
  • -H suppress Headers -I Inserts instead of csv -R to give ; as the row delimeter. Probably you can concatenate each line with a ; while importing to the db.

    mdb-export -H -I -R database.mdb table >table.sql
    vasundhar · 2011-04-09 22:18:24 0

  • 0
    nmap -sP <subnet>.* | egrep -o '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' > results.txt ; for IP in {1..254} ; do echo "<subnet>.${IP}" ; done >> results.txt ; cat results.txt | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 | uniq -u
    bortoelnino · 2010-01-22 00:26:42 1

What Others Think

interesting :) <ESC> * returns all the commands in a row. <ALT><NUM><.> grabs the 'NUM' argument from the previous command and puts it in the current command. 'NUM'=0 is the command eg. #ls a b c --some output-- # #that is equal to 'ls b'
JesusSuperstar · 470 weeks and 2 days ago
formating messed up the example above eg: ls a b c --some output <ALT><0><.> <ALT><2><.> # is equal to 'ls b' you have to holt the 'Alt' key the whole time.
JesusSuperstar · 470 weeks and 2 days ago
Thanks a lot, that's awesome.
Josay · 470 weeks and 2 days ago
I don't see in which case that's interesting. To make a for loop, simply remplace the command by "*" : for i in *; do somethingWith $i; done
sputnick · 470 weeks and 2 days ago
Sputnick > because it's inserted in your command line, you can add/remove/change elements easily. And pressing 2 keys is faster than remembering the syntax for the for loop.
Josay · 470 weeks and 2 days ago
Excellent!! Thanks for this.
DaveQB · 470 weeks and 2 days ago
It also works with wildcard filtering: echo *.ogg<ESC>* # List *.ogg files echo *w*<ESC>* # List filenames containing 'w'
sunny256 · 470 weeks and 1 day ago
Seems to not work on Fedora 8/Bash
ozymandias · 470 weeks and 1 day ago
@ozymandias What version of bash are you using? Mine is 3.2.39, and it works here.
sunny256 · 470 weeks and 1 day ago
bash --version GNU bash, version 3.2.33(1)-release (i386-redhat-linux-gnu)
ozymandias · 470 weeks and 1 day ago
Whoa. Nice. Works fine here, on a gentoo machine .. "GNU bash, version 4.0.17(2)-release (x86_64-pc-linux-gnu)"
Alanceil · 470 weeks and 1 day ago
Not trying to be a hater, but stuff like this is why I use zsh. In zsh there is no mystery as to how this works, it just does. echo *<TAB> When I'm forced to use bash, I try and make it act like zsh so I can keep my sanity*. So far I've failed :) *says the long time zsh user. But seriously, give it a shot...
claytron · 470 weeks and 1 day ago
Under bash 3.2.39 I can get echo *.c to work but ls -l *.c does not. Am I doing something wrong?
bwoodacre · 469 weeks and 6 days ago
Same version, same problem. Works : echo * esc-* any_other_command esc-* echo *.c esc-* Does not work : any_other_command *.c esc-* I just can't understand.
Josay · 469 weeks and 5 days ago
Alt * Does the same; I find it easier to type.
polar · 469 weeks and 5 days ago
Work fine on ksh@AIX server ; )
Oxyaxion · 345 weeks and 4 days ago
scream, or enjoy the cicadas flap its wings when you bring the cool wind; when passing Hasuike also puffed breath goods products that Lotus aroma; hours because ignorance has been poked hornet's nest and stung his face was bruised. Dig once, because "small insects" (Sparrow) and took out a "snake" (Snake) scared to fall from the wall. Fortunately, nothing serious. Leisure time, will collect some cigarette paper folded triangle, and partners to play; (the triangle on the ground and put his hand on the ground quick photo shoot the other side of the triangle is the triangle that turned their a); and also than own older brother and sister were led to a wide flat on the grass or doing "of chicken" or "kill the lamb" of the game, before the election when one eagle, then tall in front when hens , when the rest of the chicken, the eagle chasing shot at the back of the chick, hen with open arms to protect chickens, smart dodge to keep eagle patting. Or a dozen people sitting in a circle, do a do Diushou Juan game: the hands of only one person to take the handkerchief out of his mouth in a circle singing Diushou Juan songs, danced around the circle turning quietly throw the handkerchief in the back of a person. Then run around in circles. If you have a lap behind the handkerchief patting, this people have not found the person you want to give a performance for everyone; a joke, sing songs, or back poem. Then began Diushou Juan by him or her. If this is discovered immediately took the handkerchief catch Diushou Juan people, that Diushou Juan will continue to lose, someone who can back into place; catch, and throw this man who has sat on the bit when this man will be punished performances. We will play along with a dozen "Stars over the month child" or "cat drilled 72 holes" game. (Read the article Network: I remember one summer, that the acquisition of medicinal city recovered cicada skin (medical term called cicada), catty two five. So every day, together with my brothers holding bamboo, Dianzhe plastic bags, and from the village in the woods to find a tree cicada skin, after the end of the summer, we harvest relatively big, full harvest four pounds, to buy ten dollars. The next summer we look for a summer, more than the first year looking for even more, I did not expect there to happily after being told not recovered. Cicada got hard skin, back at home after shuffling, and
zyf543 · 114 weeks and 4 days ago
This only works if bash in in emacs mode. I always work in the vi mode, and there ESC gets you in modal mode. For instance k previous line, and the usual fdcw magic :-)
bartvandeenen · 50 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands

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.


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: