History of command line

Amy (amyc@libofmich.lib.mi.us)
Tue, 17 Jun 1997 14:35:09 -0400 (EDT)

I was asked by a couple people to summarize the responses I've gotten on
this topic so here it goes:

The most overwhelming response was to just simply use the korn shell
(ksh) and the same command will work. AIX defaults to the korn shell
which is what I was used to and Solaris defaults to the born shell (sh).
I should have known this but for some reason I posted before thinking
much about it. So, I switched shells and life is much better;) Thanks
to all who contributed.

Listed below are some other options that were also suggested:

1.) Use "ksh(1)" and "unset VISUAL" and set environment variable "EDITOR=vi",
an ESC kicks you into vi mode
Use "tcsh(1)" and execute "bindkey -v", an ESC kicks you into vi mode.
Use "bash(1)" and execute "set -o vi", again, an ESC kicks you into vi mode.

2.)It depends on the shell you're using. In ksh (Korn Shell), you have two
choices: vi style editing, and emacs style editing. I use the vi style;
in my $HOME/.profile are these two lines:

export EDITOR=vi
export FCEDIT=vi

To get a previous command back, I type <esc>k, and then each additional
k that I type goes back one more command. Try "man ksh" for details.

3.)In a c-shell you can:
setenv HISTORY=XX
The XX being the number of commands that you would like the system to
remember.
Then when you type "history" at the command prompt, it will give you a
list of
the last XX commands that can be executed by typing:
!NN
NN being the command number in the list.

4.)You could add this alias to your .cshrc file

alias edit_hist 'history -h > /tmp/hist.$$; vi /tmp/hist.$$; source -h
/tmp/hist.$$; \rm /tmp/hist.$$'

This puts the history list into a temp file calls "vi" on the file
when you exit "vi" puts the contents of the file on th eend of the
history list and removes the file.

5.) This capability is NOT related to the kind of machine or operating
system; it depends on your command interpreter (shell). On an AIX
system, 'ksh' is the default shell. ksh supports the 'set -o vi'
command and the line editing options.

On Solaris, ksh is available, but it's not the default. You can
change the shell of any user with the 'usermod' command, or using
'admintool'. Consult the manual pages for details in usage and
syntax.

A word of caution - it is not a good idea to change the login shell
for the root account. The root account uses /sbin/sh because /sbin/sh
is statically linked, which means it does not depend on any shared
libraries. If a shared library is ever corrupted, you want to be able
to use the root account to fix it (recover from backups, or whatever),
but you might not be able to do so if root's shell depends on the shared
library that happens to have been corrupted.

A simple alternative is to leave the regular root shell as '/sbin/sh',
and create a second root account which uses ksh instead. You could do
this with the following 'useradd' command:

useradd -c "Root with ksh" -m -d /kroot -g 1 -s /bin/ksh -o -u 0 kroot

You'd have to assign a password for the new account:

passwd kroot

When you login as 'kroot', you'll have ksh as your default login, and
your default home directory will be /kroot. You should create a file
/kroot/.profile and put the line "set -o vi" in it. It's important to
keep separate startup files (.profile) for root and kroot, since the
bourne shell doesn't understand many ksh commands, like "set -o vi".

6.) I would suggest getting bash (bourne again shell). It allows you to
page back
through precious commands just by using the arrow keys. You can also
edit any
command that you page back to. The shell you are talking about on AIX is the
Korn Shell. The command editing in bash is much better then ksh.

\\\\\\\\\\\\\\Amy Briggs Microcomputer Support Specialist///////////////
Library of Michigan amyc@libofmich.lib.mi.us
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\////////////////////////////////////////////
** Its not what you've got, its what you give--TESLA **