LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   question about bash completion (http://www.linuxquestions.org/questions/linux-software-2/question-about-bash-completion-419145/)

Guest1234 02-24-2006 12:09 PM

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?

RHELL 02-24-2006 12:58 PM

Have you tried 'tab'?

Guest1234 02-24-2006 01:02 PM

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")

sipsipi 02-25-2006 11:00 AM

Using the history command is your friend.

Valdis Grinbergs 02-25-2006 04:09 PM

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.


All times are GMT -5. The time now is 08:53 PM.