complete -W "$(echo $(grep '^ssh ' .bash_history | sort -u | sed 's/^ssh /\"/' | sed 's/$/\"/'))" ssh

SSH Autocomplete. Takes your history and creates ssh autocomplete using tab

Type the command. Then just use ssh command with tab to see all your ssh sessions. You can also put it in your profile. Thank you Nedzad !

0
By: bojan
2012-11-02 15:14:15

These Might Interest You

  • There's probably a more efficient way to do this rather than the relatively long perl program, but perl is my hammer, so text processing looks like a nail. This is of course a lot to type all at once. You can make it better by putting this somewhere: clf () { (curl -d "q=$@" http://www.commandlinefu.com/search/autocomplete 2>/dev/null) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/<a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +|\([0-9]+ votes,//g;s/^\//http:\/\/commandlinefu.com\//g'; } Then, to look up any command, you can do this: clf diff This is similar to http://www.colivre.coop.br/Aurium/CLFUSearch except that it's just one line, so more in the spirit of CLF, in my opinion. Show Sample Output


    1
    (curl -d q=grep http://www.commandlinefu.com/search/autocomplete) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +//g;s/^\//http:\/\/commandlinefu.com\//g'
    isaacs · 2009-07-08 22:10:49 4
  • Change bash autocomplete case search to insensitive when pressing tab for completion.


    3
    shopt -s nocaseglob
    josx · 2009-03-17 17:51:42 2
  • Could use your ssh bash history if your known_hosts are hashed and you want to keep it hashed


    -3
    complete -W "$(echo `cat .bash_history | egrep '^ssh ' | sort | uniq | sed 's/^ssh //'`;)" ssh
    kulor · 2009-07-24 09:48:46 2
  • Autocomplete from .ssh/config


    1
    complete -W "$(echo $(grep ^Host ~/.ssh/config | sed -e 's/Host //' | grep -v "\*"))" ssh
    nathancahill · 2014-09-20 19:16:24 1
  • Rainbow Stream is a smart and nice Twitter client on terminal. Almost everything you can do with a GUI application can be done, even viewing an image. - Tab-autocomplete, history browsing - Beautiful built-in themes and custom configuration support - Tweet's images directly on your terminal. Show Sample Output


    0
    sudo pip install rainbowstream && rainbowstream -iot
    DTVD · 2014-08-20 06:45:16 0
  • Stop tormenting the poor animal cat. See http://sial.org/howto/shell/useless-cat/. Edit: replaced sort | uniq by sort -u


    11
    complete -W "$(echo $(grep '^ssh ' .bash_history | sort -u | sed 's/^ssh //'))" ssh
    0x89 · 2009-07-25 23:07:25 2

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?

commandlinefu.com 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.

» 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: