Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tab / History Completion
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Lactic
n00b
n00b


Joined: 18 Jun 2002
Posts: 34
Location: Earth [Minneapolis]

PostPosted: Tue Aug 19, 2003 5:00 am    Post subject: Tab / History Completion Reply with quote

I noted this on #gentoo and someone who had used LINUX for two years had not heard of these, so I thought I'd toss it up for kicks.

Welcome to BASH, a very neat shell. In BASH, you can begin typing a program name, file name, directory name, etc. and press tab. When tab is pressed, your current or specified directory, and anything in your PATH environment variable for a matching command to auto-complete with.

As an example, if you have reiserfsprogs (utilities for ReiserFS) installed, type `reis` and press tab twice. You will see 'reiserfsck reiserfstune' below your prompt, receive a new prompt, and you will have 'reiserfs' on the command line, waiting for you to continue typing the command you want. (This occurs because these two commands match up to that point, where one finishes with 'fsck' and the other 'tune'.)

Another thing you can do is history-search partial completion. So let's say you used your tab completion to run reiserfstune. But you forgot a flag and killed it. Now you can type "r" and press pg-up. Voila, BASH searches your command history for the first command that begins with 'r' and allows you to add the flags you need. If you go past the command you wanted in your history, press pg-dn to go back one command.

I know this is not the greatest explanation, but play with these and you'll get it.
_________________
Linux: The best text adventure game ever.
Back to top
View user's profile Send private message
smiler.se
Tux's lil' helper
Tux's lil' helper


Joined: 18 Aug 2003
Posts: 115
Location: Sweden - Europe - Earth

PostPosted: Tue Aug 19, 2003 5:10 am    Post subject: Re: Tab / History Completion Reply with quote

Lactic wrote:
Another thing you can do is history-search partial completion. So let's say you used your tab completion to run reiserfstune. But you forgot a flag and killed it. Now you can type "r" and press pg-up. Voila, BASH searches your command history for the first command that begins with 'r' and allows you to add the flags you need. If you go past the command you wanted in your history, press pg-dn to go back one command.


Actually you need to press ctrl + r
But the reason I use bash infront of ie. zsh is the bash-completion packagage that allows you to complete more than just the commandname. You can for example type ssh my.<tab> and it will expand to ssh my.example.host if you have my.example.host in your ~/.ssh/known_hosts
For more info checkout the app-shells/bash-completion ebuild
_________________
Christian

Sig out of date. Please upgrade to a newer one.
Back to top
View user's profile Send private message
Lactic
n00b
n00b


Joined: 18 Jun 2002
Posts: 34
Location: Earth [Minneapolis]

PostPosted: Tue Aug 19, 2003 5:22 am    Post subject: Re: Tab / History Completion Reply with quote

smiler.se wrote:
Actually you need to press ctrl + r

Well, pg-up/dn works on my laptop, and on my Uni account (CSH).
Following my example,
Code:
[user@host] % re <CTRL+R>
-bash: re: command not found
(reverse-i-search)`': re

This is what I get. But if I type 'history', I get my history. Weird on this sytem. But anyway, this isn't a tech support forum =)

[edit] Actually, I just remembered, I think you have to enable this in your .bashrc, but I'm not certain.[/edit]

smiler.se wrote:
But the reason I use bash infront of ie. zsh is the bash-completion packagage that allows you to complete more than just the commandname. You can for example type ssh my.<tab> and it will expand to ssh my.example.host if you have my.example.host in your ~/.ssh/known_hosts
For more info checkout the app-shells/bash-completion ebuild

I've just emerged this, but haven't played yet. It sounds nice though.
_________________
Linux: The best text adventure game ever.
Back to top
View user's profile Send private message
funkmankey
Guru
Guru


Joined: 06 Mar 2003
Posts: 304
Location: CH

PostPosted: Tue Aug 19, 2003 5:41 am    Post subject: Reply with quote

tcsh has always been the cadillac of shells for tab-completion and emacs-command goodness.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum