Operating System - HP-UX
1833189 Members
2853 Online
110051 Solutions
New Discussion

Command completion with tab using Posix shell

 
SOLVED
Go to solution
John Bray_1
Occasional Advisor

Command completion with tab using Posix shell

Is there any way to change the command completion sequence from double escape to Tab in the Posix shell. This would make my combined Linux/HPUX admin much easier. I know this can be done using pdksh, but I do most of the work as the root user, and don't want to change its shell.
9 REPLIES 9
T G Manikandan
Honored Contributor

Re: Command completion with tab using Posix shell

You can just give like

$EDITOR=vi
$export EDITOR
$set -o vi

Try the command completion.
To make changes permanent put it inside .profile file of the user

Revert
John Bray_1
Occasional Advisor

Re: Command completion with tab using Posix shell

I normally use set -o emacs, and changing it to set -o vi does not help

John
Ralph Grothe
Honored Contributor

Re: Command completion with tab using Posix shell

I think the tab command, path, hostname etc. completion is thanks to the READLINE library.
I don't know what HP-UX's equivalent is.
But I know that Bash is using it.
Bash also parses /etc/inputrc and $HOME/.inputrc where you have many additional bells and whistels.
If you're unhappy with Esc, Esc of HP-UX's sh-posix you can always get the sources of Bash from the FSF and build your custom shell from them.
Madness, thy name is system administration
A. Clay Stephenson
Acclaimed Contributor

Re: Command completion with tab using Posix shell

Don't let anyone talk you into changing the root shell. You will have an unbootable machine but you won't know it until you boot. Root's shell (/sbin/sh) is a statically linked version of the POSIX shell. Unless you are very careful to create a statically linked version of bash then you will not have a functional shell in single-user when /usr is not mounted.

I'm also a little concernewd that you indicate that you do most of your work as root user. You should really be doing most of your work as a regular user and then su'ing to root only as needed. This helps to keep you from being your own worst enemy.
If it ain't broke, I can fix that.
John Bray_1
Occasional Advisor

Re: Command completion with tab using Posix shell

I too am very wary of changing root's shell to anything else.

Re working as root. My main development machine is Linux, and I avoid root there. For the HP-UX machines my changes are generally sys-admin ones that need root privleges rather than user level access.
Steven E. Protter
Exalted Contributor

Re: Command completion with tab using Posix shell

Are you trying to imitate Linux behavior?

I find the arrow keys on Linux less intutive than escape k on HP-UX 'cause I learned UX first.

I have been advised against trying to make Linux work likd UX and vice versa.

You need to consider what happens when you're on your dream vacation, climbing a mountain or whatever and someone else needs to work on your system.

Changing default shell behavior will confuse them and slow them down. You are right to not tocuh the root shell. It would be more fun to play with dynamite.

STeve
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
steven Burgess_2
Honored Contributor

Re: Command completion with tab using Posix shell

Hi

Do you use an emulator for your sessions ?

You could use keyboard macro's to assign the value of tab to escape

HTH

Steve

take your time and think things through
Ralph Grothe
Honored Contributor
Solution

Re: Command completion with tab using Posix shell

I think I have to get something straight with regard to root's login shell.
I never meant to suggest to change root's login shell whatsoever
(though you can build a statically linked Bash from the Bash sources that you copy to /sbin, see "Configure --help")

Indeed I have given the root acount Bash as kind of a pseudo login shell on some of our HP-UX boxes.
But I didn't touch the 7th field of /etc/passwd at all.

The safe way to do it is to exec a Bash during login.
Therefore one only has to modify root's .profile.

First I created a .bash_profile (with special settings that take care of the extended features of Bash, e.g. prompting).
Then I also created a .bashrc (which holds alii and func definitions for my Bash sessions).
Read the manpage of Bash to find out the way and order in which Bash looks for configuration files.
In the original .profile I would place a test to look for a Bash executable like

if [ -x /usr/bin/bash ]; then

That would safe you from trying to switch root's login shell during maintenance mode.

If the above condition evaluates true we know that /usr is mounted and Bash is available.

Finally as last statement in .profile I'd exec a login Bash

exec /usr/bin/bash --login

In .bash_profile I'd also source .bashrc and

export BASH_ENV=$HOME/.bashrc

to get the alii also for the pseudo login Bash.





Madness, thy name is system administration
John Bray_1
Occasional Advisor

Re: Command completion with tab using Posix shell

I think a modified form of Ralph's suggestion is probably the best. I've put bash in the PATH, so all I need to remember after logging in is to type 'bash' and then carry on that way. If other users come in as root they won't be confused.

Thanks for all your suggestions.

John