LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-24-2006, 12:09 PM   #1
Guest1234
Member
 
Registered: May 2004
Distribution: Ubuntu
Posts: 33

Rep: Reputation: 15
question about bash completion


In my office I have tcsh and if for example I typed the following commands(in this order):
ls programming
cp bla.txt ~/tmp

and then I type:
"ls" and then the up key then it will complete to "ls programming"

on bash in my ubuntu if I type the "ls" and then the up key it will complete me to "cp bla.txt ~/tmp" since its the most recent command.

How do I configure my bash to act like tcsh in this matter?
 
Old 02-24-2006, 12:58 PM   #2
RHELL
Member
 
Registered: Feb 2004
Location: Outermost mingetty
Distribution: RHEL3,RH4U4,Sol9, Sol10
Posts: 321

Rep: Reputation: 31
Have you tried 'tab'?
 
Old 02-24-2006, 01:02 PM   #3
Guest1234
Member
 
Registered: May 2004
Distribution: Ubuntu
Posts: 33

Original Poster
Rep: Reputation: 15
How would tab help me?

tab completes a command(without the parameters) or a file but not the whole line.
If for example I have a command like:

"find . --max-depth 1 -type f -exec rm \{} \;"
and I type afterwards the command:
"cp bla.txt ~/tmp"

Then when I type "fi" and the up key I would like it to complete the whole line:
"find . --max-depth 1 -type f -exec rm \{} \;"

and not "cp bla.txt ~/tmp"

tab in this case would only complete "fi" to "find"(and that's if there isn't any other command that starts with "fi")

Last edited by Guest1234; 02-24-2006 at 01:08 PM.
 
Old 02-25-2006, 11:00 AM   #4
sipsipi
Member
 
Registered: Dec 2005
Location: Chicago
Distribution: Fedora and Redhat
Posts: 86

Rep: Reputation: 15
Using the history command is your friend.
 
Old 02-25-2006, 04:09 PM   #5
Valdis Grinbergs
Member
 
Registered: Dec 2005
Distribution: Debian
Posts: 30

Rep: Reputation: 25
Guest 1234,

To recall previous commands from the command history in bash, press ctrl-r.
You will be prompted as follows:
(reverse-i-search)`':
Start typing the first or first few characters of the previous command you want to repeat. Bash will search the command history backwards and display the first match. In your example, all you need to type is l and the prompt will display :
(reverse-i-search)`': ls programming
Then press enter to execute the command again.

If you want to learn more ways to use the command history in bash, open man bash or info bash and search for history.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
? about code completion tool. -> RHLinuxGUY Programming 6 03-06-2006 12:32 AM
Can we enable bash completion in Sarge?How?Please help... deepclutch Debian 6 12-02-2005 07:02 PM
code completion in KDevelop dvm Programming 1 05-15-2005 06:35 AM
What is the + or - on the completion of a bg job? davee Solaris / OpenSolaris 2 05-05-2005 07:10 AM
auto-completion in bash with wildcards juanbobo Linux - Software 2 04-07-2005 12:56 AM


All times are GMT -5. The time now is 09:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration