 |
 |
Tab Autocompletion in the terminal. . .?
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2007
Status:
Offline
|
|
Hi All,
I'm interested in tab completion in the terminal. In most linux distributions you can type anything on a command line, and as long as it follows suit with the command it will tab complete. For instance:
1) If I type 'sudo xte' in Linux, I can simply press tab and it will autocomplete 'xterm'. However, in OS X, it seems to only want to autocomplete the first command and *ONLY* the first command ('sudo' in this case). This is annoying. It should perpetually autocomplete. I've tried every shell to no avail.
2) Also, in previous builds of OS X, I was able to type 'defaults read com.apple.' and it would autocomplete the "com"s. . .what has changed and why won't it do this anymore?
. . .any ideas as to how to remedy either of these?
Regards
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Works exactly the same as for linux for me. Auto completion of the first 'word' on the line in the shell searches for commands (using your path environment variable). After the first 'word' it searches for files using the current working directory, or the directory you've typed in so far in the current 'word'.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2007
Status:
Offline
|
|
Thank you, but that's not what I'm speaking of. I mean 'commands' and 'commands' specifically. For instance, let's compare using 'apt-get' in Linux to that of OS X (provided by either fink or darwinports). I can tab complete every single 'word' in Linux, regardless of the current working directory:
sudo apt-get install my_favorite_program
I can type 'su' TAB 'apt-g' TAB 'inst' TAB. . .et cetera, et cetera. Neither 'sudo' nor 'apt-get' (nor the 'install' option for apt-get) are in my pwd. Linux (say Ubuntu in this case) apparently references PATH as well. So I suppose I need to figure out a way to get terminal to reference PATH when tab completing.
. . .and still need a fix for the 'defaults read com.apple' stuff as well
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2002
Status:
Offline
|
|
It's likely the default bash configuration is different in OS X. Perhaps copying over some of the settings will help.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
as I said, I get the exact same behaviour in both RedHat Linux and Mac OS X as what you describe for Mac OS X.
It is likely not an OS-specific issue, but rather a shell-specific, or even shell configuration issue, or perhaps an environment issue.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2007
Status:
Offline
|
|
Originally Posted by Brass
as I said, I get the exact same behaviour in both RedHat Linux and Mac OS X as what you describe for Mac OS X.
It is likely not an OS-specific issue, but rather a shell-specific, or even shell configuration issue, or perhaps an environment issue.
I don't doubt that it's a shell configuration issue. I just need to know *what* needs to be done. In this case GOOGLE simply hasn't been my friend. 
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status:
Offline
|
|
Eh... The first word is autocompleted to any command in your path. The second is autocompleted to any filename in the current directory. That's the default behaviour, and I'm not aware of an OS that does it differently. What you're describing seems to be some sort of special treatment of sudo. Where did you see that? Could you please send me the config files if you find it, I'd love that feature.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2007
Status:
Offline
|
|
Other distros do it, but give Ubuntu a try. There seems to be nothing special about any of the configuration files. I'm not sure what's going on. But, to rehash, I can do the following:
su[TAB] apt-ca[TAB] pkg[TAB]
and I'll get the following
sudo apt-cache pkgnames
. . .for whatever reason Ubuntu seems to support both multiple 'commands' (not just the first 'word' on a line) as well as options for certain commands. Still if the terminal in OS X can recognize files in the 'pwd', why can't one simply add PATH to the available type-ables (I'm sure that's a word somewhere) in the command line? Perhaps it is a special allowance for 'sudo'. Either way, I want it. 
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
how is your path set up? What do you get when you do a:
echo $PATH
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
Two things:
1. Your .inputrc
You should edit your .inputrc (creating it if necessary) to include the following lines:
[codex]# completion
set show-all-if-ambiguous on
set completion-ignore-case on
# history
"\e[A": history-search-backward
"\e[B": history-search-forward[/codex]
2. Bash completion extensions.
Run, don't walk, to Caliban.org and download the bash completion extensions there. This file contains the various per-application completions that you refer to. The installation is straightforward -- stick the file somewhere, edit the file so that it knows its own location, and add a line in .bashrc to source that file.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2007
Status:
Offline
|
|
Yeah, I'd actually come across Part 1 using Google. Part 2 doesn't seem to be of much use. What exactly does it do?
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Mar 2004
Status:
Offline
|
|
Originally Posted by gberz3
If I type 'sudo xte' in Linux, I can simply press tab and it will autocomplete 'xterm'. However, in OS X, it seems to only want to autocomplete the first command and *ONLY* the first command ('sudo' in this case). This is annoying. It should perpetually autocomplete. I've tried every shell to no avail.
$ type -a xterm
-bash: type: xterm: not found
Um... something (like a command) has to actually EXIST
before auto-complete can do what it's supposed to do.
[maybe that wasn't the most universal example to post]
But, it looks like you may have a point after all.
I too will follow the suggestions posted by Mithras...
because " sudo chmo<tab>" also fails with a whimper.
[which is odd, since ^x- ! prints chmod on a new line]
(Last edited by Hal Itosis; Jun 9, 2007 at 01:43 PM.
)
|
|
-HI-
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
Part 2 does what you asked for! i.e. it defines autocompletes for a bunch of standard programs, so that your shell will know that after ssh you're going to type a hostname, etc.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|