Setting vi or emacs to be COMMAND LINE EDITOR in csh???

Setting vi or emacs to be COMMAND LINE EDITOR in csh???

Post by Dan LeGa » Sat, 27 Jan 1996 04:00:00



In csh is there an equivalent to ksh's ability to issue:

set -o vi
  or
set -o emacs

to have a vi or emacs-like command line editor?  If not,
is there ANY way to scroll back through previous commands?

Thanks.

Dan

 
 
 

Setting vi or emacs to be COMMAND LINE EDITOR in csh???

Post by Jerry Heym » Sat, 27 Jan 1996 04:00:00


: In csh is there an equivalent to ksh's ability to issue:

: set -o vi
:   or
: set -o emacs

: to have a vi or emacs-like command line editor?  If not,
: is there ANY way to scroll back through previous commands?

Not easily.  You will probably be better off with tcsh.

csh does give you some editing capabilitiles, but exactly the way
you would want them (if you're used to ksh).  A combination of the
history command, and judicious use of the ^string^new_string combination
will allow you to edit a line...

: Thanks.

: Dan

jerry
--

Tactical Simulation Division   | http://www.arlut.utexas.edu/~jerry/main.html
Applied Research Laboratories of UT Austin | "Software is the difference
P.O. Box 8029, Austin, TX 78713-8029       |     between hardware and reality"

 
 
 

Setting vi or emacs to be COMMAND LINE EDITOR in csh???

Post by Brian S Hile » Tue, 30 Jan 1996 04:00:00


: In csh is there an equivalent to ksh's ability to issue:
: set -o vi
:   or
: set -o emacs
: to have a vi or emacs-like command line editor?  If not,
: is there ANY way to scroll back through previous commands?

I agree with the stated opinions of the previous respondents: get tcsh
or use the features of csh that you do not know yet to their best avail.
But for what it's worth, this code comes from "Unix Power Tools" (highly
recommended). I have never used it, thinking csh the "spawn from hell" ;-)
Best of luck!

-brian

# (The name of the author of the script below, which apparently was obtained
# from Usenet years ago, has been lost.)
#
# This script gives csh users the capability of command line editing by
# invoking the open mode of ex on a file containing a history list, and then
# sourcing the edited version of the desired command.
#
# 1) install it in /usr/local/bin/redo (or wherever else you'd like) with
#    read-only-for-world permissions (i.e., do *not* make it executable);
#
# 2) do
#       alias r source /usr/local/bin/redo
#    (or whatever, corresponding to where you installed it), and also put this
#    alias in your favorite "dot" file;
#
# 3) type "r" to invoke it; use the "hjkl" keys to get to the line you want to
#    edit; edit the line (remember that you're in the open mode of ex); and,
#    when you're done, hit <CR> (*not* ZZ).
#

# Get up to 22 most recent commands.
history -h 22 >! /tmp/redo.$$

# Put CR in $c[1] and ESC in $c[2]:
set c=(`echo "m e" | tr me '\015\033'`)

# Make CR map to :wq! and start ex quietly at 2nd to last line in open mode.
(setenv EXINIT "map $c[1] :.wq\!$c[2]|map! $c[1] ${c[2]}:.wq\!$c[2]";\
        ex '+$-1 open' /tmp/redo.$$)
tail -1 /tmp/redo.$$ >! /tmp/cmd.$$

# Insert into history without executing.
source -h /tmp/cmd.$$

# Clear out temporaries.
/bin/rm -f /tmp/{cmd,redo}.$$
unset c

# If thing chosen to redo is the redo alias itself then DON'T redo it.
if (!-2:0 != !!:0) !!

--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  

__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__

 
 
 

Setting vi or emacs to be COMMAND LINE EDITOR in csh???

Post by David Grierso » Thu, 08 Feb 1996 04:00:00



> In csh is there an equivalent to ksh's ability to issue:

> set -o vi
>   or
> set -o emacs

> to have a vi or emacs-like command line editor?  If not,
> is there ANY way to scroll back through previous commands?

> Thanks.

> Dan

There's no way to do it in csh - use tcsh instead... use bind or bindkey
to determine which mapping you want to use.

        Dave.
--
 -----------------------------------------------------------------------
  David Grierson
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.3a

mQCNAjEFLYEAAAEEAMcDL1uiUSzNEhXtg4sQ1pVxTMBz43wZPuMAokrJAQg0UeLj
dc9cjTIXu/MXRu2E/PsD4xFlv4bBWC2Zjenj28HBt/hgQJhyUiZTJ9naft476dSA
+drT+Lx5S2Y/HpfJMJ7KbHtJE3OKiW0HDY3q29zCyBpyInMhkXXewNCSN8iVAAUR
tCNEYXZpZCBHcmllcnNvbiA8bW0yMzZAbmFwaWVyLmFjLnVrPg==
=C45G
-----END PGP PUBLIC KEY BLOCK-----