Shell – TAB autocomplete in Bourne Shell

autocompleteos390shellssh

I don't know how to get the TAB key to autocomplete filenames, commands, or anything at all.

I'm on a Unix-like system (OS/390) and depend on several scripts that work in sh (Bourne shell, not BASH), but not in other shells (tcsh, for example), so I can't switch shells. I usually connect to this system via ssh or telnet from Ubuntu's GNOME Terminal running bash locally. Other people connect to the OS/390 system via telnet from the Windows XP command prompt, and they are able to autocomplete with the TAB key after issuing "set -o emacs". When I issue "set -o emacs", I get some of the appropriate functionality (ctrl-p to step backward through the history, for example), but not autocomplete.

I am aware of the "set -o vi" option, but using "ESC-*", etc does not appeal to me because I know that the simple TAB key works for other people.

Is there something about Ubuntu, the GNOME Terminal, bash, or ssh that sends a different tab character than a Windows XP command prompt running telnet?

Does anyone have an idea as to why I might not be able to get tab to autocomplete while people on that same remote machine, running the same shell, can?

What should be done in order to enable tab auto-complete?

Best Answer

(No answer to your exact question, but many workarounds.)

You don't need to match your scripting shell with your interactive shell. (For example, most (t)csh or zsh users write sh scripts). If you have or can install a better interactive shell than the Bourne shell (zsh, bash, tcsh), go for it. Even if you can't, look if there's a ksh, which is likely to have slightly better interactive features than a Bourne shell.

You can check what character the tab key sends by entering echo ' Ctrl+V Tab ' | od -t x1 Enter. 0000000 09 0a (i.e. at position 0, two characters, a tab and a newline) is the expected output. I don't expect this to be the issue.

If you can't get a comfortable environment, you could try doing more things remotely, using your local machine for interaction as much as possible. This has its ups and downs.

  • From Linux (or most other unices including OSX, but not from Windows), you can use sshfs to access the remote filesystem.
  • Within Emacs, you can easily browse remote files via Tramp (open /os390hostname:/path/on/remote/machine, you get completion). You can also use Eshell to get a remote shell interface (an Emacs built-in shell); if you change to a remote directory (cd /os390hostname:/path/on/remote/machine), the external commands you launch will be executed on the remote machine. If you need to run commands as root, Tramp (and Eshell which is based on it) can combine ssh with su or sudo.
Related Question