bash autocomplete for ssh

hi,

long time i havent posted anything. but here is something that i cooked up over last weekend. the use case is that i keep sshing to a set of machines from my box. And its difficult to remember the exact host names and stuff. so i wanted something like autocomplete we use for ls or vim commands. Without much ado here is the code for making my thing to work.

add this text to your .bashrc or .bash_profile

_compssh ()
{
cur=${COMP_WORDS[COMP_CWORD]};
COMPREPLY=($(compgen -W '$(/bin/cat ~/hosts_list) --all --schema' -- $cur))
}
complete -F _compssh ssh

and the contents of ~/hosts_list are something like this

database1.silver.sympa
webserv1.silver.sympa
data1.gold.sympa

dont mind the names they are servers internal to my network. but you can edit ~/hosts_list file for any number of hosts
Then just sit back and do ssh +[tab] and it will show all possible completions.
thats it for now. i got lot of insight from Brock Noland from bashcurescancer.com
PS: i have tested this on GNU bash, version 3.2.0 not sure how things work on other shells. But i guess that should not be difficult to patch it and make it work
good byeee.
Happy sshing…

1 comment March 20, 2008

Cricket Scoreboard -kde desktop

hi,

i made a small script to put a scoreboard of current cricket match.. here is the script

it requires the following software.

–> links or elinks ( a command line web browser)
–> Kdialog dialog utility in kde (generally default in all linux dists)

score.sh

#!/bin/sh
url="http://www.cricbuzz.com/livecricketscore/2007/2007_IND_PAK/IND_PAK_NOV30_DEC04/commentary.html"
#this needs to be changed to current match page on cricbuzz.com
while [ 1 ]
do
        links -dump $url > dump
#       info=`cat dump | awk -f score.awk | tail -3`
        info=`head -n 10 dump`
  kdialog --passivepopup "$info" 10
  sleep 60

done

there it is .. try and enjoy. :)

5 comments December 4, 2007

Make your site search engine friendly.

hi,
long time i havent blogged.
this is mainly regarding “how to make our site more easily searchable by internet Search engines”
for optimizing for search here are some basic steps you can take..

1. for each page have a unique URL so that while crawling its easy for follow links based on that.. (avoid using ajax based content fetching.)

2. have a RSS feed and include it in public RSS readers like. http://www.mybloglog.com/ , www.bloglines.com , google reader etc etc. This help in pulling data from the server and be cached on others.. by starting communities and discussions the linkIn to site increase drastically. particularly helpful for pragyan.

3. you need to register your domain on many online directories.. examples are dir.yahoo.com

4.Also submit your search for it to be crawled check http://submit.search.yahoo.com/free/request .
5. further check the site explorer of yahoo https://siteexplorer.search.yahoo.com/mysites here i think it needs to authorize the exploring process.

6. for google there is option called addUrl http://www.google.com/addurl/?continue=/addurl

7. further site searchability can be enhanced by submitting site url in directories like Open Directory Project (dmoz.org ), or MSN Directory are noticed by the Yahoo! Web Crawlers.

thats all i found.. feel free to pour in suggestions for the same.

PS: found good FAQ on above topic here.. http://help.yahoo.com/l/us/yahoo/search/index.html

1 comment November 30, 2007

Bash History

In case, history command does not save commands that you executed in the previous session, you can enable it by putting this in your .bashrc

export HISTFILE=~/.bash_history

CtrlR on bash prompt reads from the “history” itself.
So if history does not work, CtrlR also won’t work

Add comment September 12, 2007

Firefox Shortcuts

Do you type in URLs of well known sites over and over and over again? I’ve been doing it for years because I couldn’t think of a better way to browse to frequently used sites. I didn’t want to create bookmarks for two reasons. One, I use several different machines and keeping them all in sync would be a pain. Two, the more bookmarks you get, the harder it is to find the one you’re looking for and it’s faster to just type the URL instead of searching through all your bookmarks to find the site. Now I’ve found an easier way.

First, use Foxmarks. It synchronizes your bookmarks across any number of Firefox installations, so you can create a bookmark in any of the browsers you use and the bookmark will be propagated to the rest of the instances.

Second, use the keyword field.

I’ve now bookmarked those sites and added a keyword to each one, so instead of typing in http://www.flickr.com/photos/username (which I’ve done hundreds of times) I type the ‘fl <username>’ keyword into the URL field to visit my web site.

Heres how you do it.

In Firefox, go to the bookmark management/organization section. Create a new bookmark.



Name: Movable Type

Location: http://www.flickr.com/photos/%s
Keyword: fl

PS: You can also use for search and stuff. Also It doesn’t have to be used only for sites that accept queries. In the past I only used quick searches for places like Yahoo and Sourceforge because it was convenient to type a search phrase and go directly to the results page. It recently dawned on me that I could do the same with other frequently visited sites.

1 comment September 4, 2007

Linux Fonts

hi,

i tried installing hindi fonts in my linux system..

my sysconfig is FreeBSD 4 and KDE ver 3.4 but i guess that the basic configuration of all KDE should work fine..

1. download the required fonts to any directory..

http://tdil.mit.gov.in/download/openfonts.htm
http://www.sanskritweb.org/cakram/

2. goto X11 directory of you system.. it something like /usr/X11R6/lib/X11/fonts/
3. create a directory with any name like hindiFonts [ you may need to be root user. if yes do su and then mkdir]
4. run the following commands
$> mkfontdir hindiFonts
$> mkfontscale hindiFonts
5. you are almost done. all you need to do is now add the following line in your /etc/X11/XConfig file under the
Section “Files”
FontPath “/usr/X11R6/lib/X11/fonts/hindiFonts/”
..
..
EndSection
6. save and restart your X. and you are done..

Add comment August 30, 2007


Archives

 

February 2010
M T W T F S S
« Mar    
1234567
891011121314
15161718192021
22232425262728

mybloglog rr

Blog Stats