Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'reeeealy short' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
reeeealy short
Authored by: trevden on Nov 28, '01 04:09:53AM

I like one-character commands. In my tcshrc are things like

alias b bbedit
alias p "ssh" #powerbook
alias t "ssh" #tower

[ Reply to This | # ]
More than ssh
Authored by: Cadre on Nov 28, '01 12:30:16PM

Those are fine if you aren't doing much.

The real utility of the hostname completion is evident if one has to work with a large amount of hostnames. e.g.: My completions file currently contains 30 hosts of the servers that I work on regularly.

ssh was merely an example. Many other commands use hostnames and are setup in the completions file to expand hostnames (finger, ping, traceroute, ftp, ...)

[ Reply to This | # ]
How much more than ssh?
Authored by: serversurfer on Nov 28, '01 11:10:07PM

Could you post a completion for scp by any chance? Pretty please? I'm too lazy/busy to figure out how they work. I'll take one of the list_all_hostnames flavor, please. ;)
If you don't have one handy, don't worry about it.

[ Reply to This | # ]
This much more than ssh!
Authored by: Cadre on Nov 29, '01 03:11:02PM

Wow! Trying to find a pattern that matches for both styles of scp was a pain in the ass (the first style being transfering a file to a server the second being receiving a file from a server). I eventually found one that partially worked and modified it to work better.

I recommend only using the first completion. The second two completions, well, they are for when you want to show off. :-)

# Simple by Aaron Linville <>
complete {scp,rcp} 'C@[./]*@f@' 'n/*/`list_all_hostnames`/:'

# From Michael Schroeder <>
# This one will rsh to the file to fetch the list of files!
#complete rcp 'c%*@*:%`set q=$:-0;set q="$q:s/@/ /";set q="$q:s/:/ /";set q=($q " ");rsh $q[2] -l $q[1] ls -dp $q[3]*`%' 'c%*:%`set q=$:-0;set q="$q:s/:/ /";set q=($q " ");rsh $q[1] ls -dp $q[2]*`%' 'c%*@%`list_all_hostnames`%:' 'C@[./$~]*@f@' 'n/*/`list_all_hostnames`/:'
#complete scp 'c%*@*:%`set q=$:-0;set q="$q:s/@/ /";set q="$q:s/:/ /";set q=($q " ");ssh $q[2] -l $q[1] ls -dp $q[3]*`%' 'c%*:%`set q=$:-0;set q="$q:s/:/ /";set q=($q " ");ssh $q[1] ls -dp $q[2]*`%' 'c%*@%`list_all_hostnames`%:' 'C@[./$~]*@f@' 'n/*/`list_all_hostnames`/:'

Now a couple notes on typing the correct patterns to match mine. When transfering files, remember to put dot slash at the beginning of the files to be transfered (yes, it does work with a list of files!!!). When sending files, if you would like completion when specifying the destination directory or file, you need to remember the dot slash at the beginning of the path also.

One last thing, you can't specify a username for a host (this breaks the pattern matching). Of course, you really shouldn't be specifying a username on the commandline. Specify the username in your ./.ssh/config file. i.e.:

Host *
User linvilaw

So following are example commands that could have been generated with completion:
linville:home %scp ./source.c
linville:home %scp ./source.c

[ Reply to This | # ]
I fixed the username!
Authored by: serversurfer on Nov 29, '01 05:51:34PM
A little playing around with Cadre's complete yielded:
complete {scp,rcp} 'C@[./]*@f@' 'c/*@/`list_all_hostnames`/:' 'n/*/`list_all_hostnames`/:'

This will still allow you to tab-complete hostnames after specifying a username.
scp root@ot[TAB]

scp root@otherhost:

I wanted this because sometimes I do work on other boxen as root, but I agree with Cadre's assertion that you should specify your normal username for the other box in ~/.ssh/config.

[ Reply to This | # ]