You are not logged in.

#1 2009-09-08 13:33:35

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Smarter auto-completion

I once sat at a terminal which had a very smart auto-completion: Say I had the command history

man gcc
man gfortran
cd Dat_F/Exercise_2
tar -zxvf fortran2.tgz
rm fortran2.tgz
ls -l
nano /etc/pacman.conf
sudo nano /etc/pacman.conf
sudo pacman -Suy

and I wanted to use a tar command similar to the one on line 4. Usually I would use the up arrow a lot of times till I finally got to the tar command. But with the smart auto-completion, I simply had to type "t" and then use the up arrow - then it would only cycle though the events in the command history starting with a "t".

Does anyone know how to get this smart auto-completion?

Offline

#2 2009-09-08 13:57:02

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: Smarter auto-completion

If you are in bash, you can try pressing Control R to go into history search mode, You can also look into history identifiers with !.

Offline

#3 2009-09-08 14:02:26

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Smarter auto-completion

egan wrote:

If you are in bash, you can try pressing Control R to go into history search mode, You can also look into history identifiers with !.

Actually I have already looked at both these - but those are not what I'm looking for: I would like the auto-completion to be smart as explained above smile

Offline

#4 2009-09-08 15:00:07

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Smarter auto-completion


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#5 2009-09-08 16:39:02

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Smarter auto-completion

Here they say that I must write the two lines

"\e[a": history-search-backward ## shift+up-arrow
"\e[b": history-search-forward ## shift+down-arrow

in my .inputrc.

First of all, I don't have an .inputrc anywhere, so I simply tried creating one (at ~ of course).

But nothing seems to happen when I press shift+up-arrow or shift+down-arrow - with or without writing something before doing it..? hmm

Last edited by bozack (2009-09-08 16:39:43)

Offline

#6 2009-09-08 16:45:14

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Smarter auto-completion

I use this in my .inputrc. and it works fine
I think you have to source .inputrc so that it takes effect.  Or restart your terminal

Offline

#7 2009-09-08 16:52:45

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Smarter auto-completion

marxav wrote:

I use this in my .inputrc. and it works fine
I think you have to source .inputrc so that it takes effect.  Or restart your terminal

Actually I just restarted the terminal (I couldn't remember what else to do) - but it didn't change anything sad

Offline

#8 2009-09-08 17:21:17

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: Smarter auto-completion

What shell you're using? IIRC, zsh doesn't read ~/.inputrc, so if this is the shell you're using, you have to find another way to config it.


(lambda ())

Offline

#9 2009-09-08 17:29:38

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Smarter auto-completion

for zsh, ESC+p / ESC+n works out of the box : http://www.cs.elte.hu/zsh-manual/zsh_14.html


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#10 2009-09-08 17:41:08

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Smarter auto-completion

andre.ramaciotti wrote:

What shell you're using?

Sorry, I should have written that from the start: I use bash

Offline

Board footer

Powered by FluxBB