[comp.unix.shell] Aliases for csh command line editing

rkaminsk@umvlsi.ecs.umass.edu (Robert D. Kaminsky) (12/17/90)

I find the following aliases useful.  Possibly you will too...

The first two aliases allow for command line editing from the history.
They are meant to be used only in the csh.  The next two aliases print the
history in 2 and 3 column format.

Just source (i.e source filename) the stuff below "CUT HERE".

--------------------------------- CUT HERE -------------------------------
#  The following aliases allow for editing commands given in the csh.
#
#     e n  -  visual edits command n (as numbered by history)    
#     ee   -  visual edits last command
#
#  Note: Both use an invisible work file called ".e_cmd" in the home directory.
#
#  By Robert Kaminsky  11/19/90

alias e '( history | sed -n "/^ *\!*[^0-9]/p" | sed 's/.......//' ) >&! ~/.e_cmd ; \vi -w002 ~/.e_cmd ; source -h ~/.e_cmd ; source ~/.e_cmd'
alias ee '( history | tail -2 | sed -n "1p" | sed "s/.......//" ) >&! ~/.e_cmd ; \vi -w002 ~/.e_cmd ; source -h ~/.e_cmd ; source ~/.e_cmd'

# ---------------------------------------------------------------------------
#  The following alias print out the command history in 2 and 3 column format.

alias his3 'history 45 | pr -3 -l15 -t | expand | cut -c1-71,72'
alias his2 'history 30 | pr -2 -l15 -t | expand | cut -c1-71,72'

tchrist@convex.COM (Tom Christiansen) (12/19/90)

[too busy to leave much comment.  just play.]

% alias e 'source ~/scripts/redo.csh'
% cat ~/scripts/redo.csh

# Edit history list at line containing last command (open mode).
# To work properly, put in .login:  alias r source ~/redo
# Origianl uthor unknown.  Mods by tchrist.
history -h >! /tmp/redo.$$

# Make CR map to :wq! and start ex quietly at 2nd to last line in open mode.
# map Q to quit and not execute
ex - '+map 

tail -1 /tmp/redo.$$ >! /tmp/cmd.$$

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

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

# If thing chosen to redo is the redo alias itself then DON'T redo it.
if ("!-2:0" != "!!:0") then
    !!
endif
--
Tom Christiansen		tchrist@convex.com	convex!tchrist
"With a kernel dive, all things are possible, but it sure makes it hard
 to look at yourself in the mirror the next morning."  -me