[comp.unix.questions] VISUAL/EDITOR = emacs in ksh

rhg@cpsolv.UUCP (Richard H. Gumpertz) (12/12/89)

I am using ksh on a AT&T 7300 (operating system release 3.51, which is roughly
equivalent to V 2) and have a few questions:

1) What is the difference between using VISUAL=emacs and EDITOR=emacs?  Why
   should I prefer one over the other?

2) My .profile does VISUAL=emacs followed by export VISUAL.  Although this
   defines $VISUAL, it does not appear to set emacs editing mode.  For that
   I have to type VISUAL=emacs manually to the shell.  Why does ksh look at
   just the variable and not the environment?  What can I do to get around
   this?

3) I would like to run the equivalent of a .profile in every sub-ksh that I
   start.  How do I go about doing that?  That is, execute a script file and
   then enter interactive mode upon invocation of ksh.
-- 
===============================================================================
| Richard H. Gumpertz rhg%cpsolv@uunet.uu.NET -or- ...uunet!amgraf!cpsolv!rhg |
| Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749      |
===============================================================================

donlash@uncle.UUCP (Donald Lashomb) (12/13/89)

In article <464@cpsolv.UUCP> rhg@cpsolv.uucp (Richard H. Gumpertz) writes:
>I am using ksh on a AT&T 7300 (operating system release 3.51, which is roughly
>equivalent to V 2) and have a few questions:
>1) What is the difference between using VISUAL=emacs and EDITOR=emacs?  Why
>   should I prefer one over the other?

If you set VISUAL to a pathname that ends in emacs, gmacs, or vi, then ksh
turns on the corresponding option no matter what EDITOR is set to - no default.
EDITOR, same thing but can be overridden by VISUAL and defaults to /bin/ed.
I usually set both of these and EDIT too, to all the same editor.  Some
programs you might use look at EDITOR, some look at EDIT.

>2) My .profile does VISUAL=emacs followed by export VISUAL.  Although this
>   defines $VISUAL, it does not appear to set emacs editing mode.  For that
>   I have to type VISUAL=emacs manually to the shell.  Why does ksh look at
>   just the variable and not the environment?  What can I do to get around
>   this?

Check out your ksh ENV file (.kshrc probably), .profile runs first, then ksh
does ENV.  AT&T-supplied .kshrc does "set -o vi -o viraw", this is overriding
your VISUAL setup in .profile.  Change it to "set -o emacs".

>3) I would like to run the equivalent of a .profile in every sub-ksh that I
>   start.  How do I go about doing that?  That is, execute a script file and
>   then enter interactive mode upon invocation of ksh.

The ENV file is executed everytime ksh is invoked.

TFB (The F***ing Book) =
	The Kornshell Command and Programming Language
	Morris I. Bolsky and David G. Korn
	Prentice Hall

hope this helps - Donald Lashomb

jbm@uncle.UUCP (John B. Milton) (12/14/89)

In article <464@cpsolv.UUCP> rhg@cpsolv.uucp (Richard H. Gumpertz) writes:
>I am using ksh on a AT&T 7300 (operating system release 3.51, which is roughly
>equivalent to V 2) and have a few questions:
>
>1) What is the difference between using VISUAL=emacs and EDITOR=emacs?  Why
>   should I prefer one over the other?
[2 and 3 deleted]

Maybe unrelated, but this line came from a strings on ksh:

fc -e "${VISUAL:-${EDITOR:-vi}}" 


John
-- 
John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu
(614) h:252-8544, w:469-1990; N8KSN, AMPR: 44.70.0.52; Don't FLAME, inform!

thad@cup.portal.com (Thad P Floryan) (12/14/89)

Re: discussion of ksh and &tc.  The following may be of interest.  Note
the DIFFERENT ksh history files depending on which "tty" I come in on
(either serial port, StarLAN port, or console window instance).  And the
"kshpr" program (source included since it's so tiny) sets up a different
prompt for me when I'm running su'd; the "normal" prompt is "parent/me>"
in terms of PIDs.

Enjoy!

Thad Floryan [ thad@cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ]

-------------------- captured session follows --------------------

ksh 1073/1074> ls -al
total 109
drwxr-xr-x  5 thad    users       432 Dec 14 00:53 .
drwxr-xr-x  9 bin     bin         144 Nov  1 03:16 ..
-rw-r--r--  1 thad    users        73 Sep 12 23:02 .caldir
-rw-r--r--  1 thad    users        19 Jul 17  1988 .calpref
-rw-r--r--  1 thad    users       368 Apr 22  1989 .emacs
-rwxr-xr-x  1 thad    users         0 Jul  4 19:04 .history
-rw-------  1 thad    users      4724 Dec 14 03:12 .kshist-p0
-rw-------  1 thad    users       126 Nov 26 01:48 .kshist-p1
-rw-------  1 thad    users        94 Nov 30 23:39 .kshist-p2
-rw-------  1 thad    users       500 Sep 14 23:36 .kshist-ph0
-rw-------  1 thad    users       140 Dec 12 12:30 .kshist-tty001
-rw-------  1 thad    users         0 Nov 21 03:02 .kshist-tty002
-rw-------  1 thad    users     12704 Dec 14 03:11 .kshist-w2
-rw-------  1 thad    users        54 Dec  1 03:44 .kshist-w6
-rwxr-xr-x  1 thad    users       314 Jul  4 19:01 .kshrc
-rw-r-xr-x  1 thad    users       390 Dec 12  1988 .kshrc-old
-rw-r-xr-x  1 thad    users       209 May  8  1989 .kshrc-old2
-rw-r--r--  1 thad    users     16413 Oct 30 02:59 .phdir
-rwxr-xr-x  1 thad    users       462 Nov 12 21:43 .profile
-rwxr--r--  1 thad    users       221 Dec 28  1987 .profile-old
-rw-r--r--  1 thad    users       222 Apr 22  1989 .signature
drwxr-xr-x  2 thad    users        32 Nov 24  1987 Clipboard
-rw-r--r--  1 thad    users       135 Sep 12 23:03 Environment
drwxr-xr-x 76 thad    users      1792 Nov  2 05:11 Filecabinet
drwxr-xr-x  2 thad    users       112 Dec  8  1987 Wastebasket
-rw-------  1 thad    users      8932 Jun  1  1989 mbox
ksh 1073/1074> 
ksh 1073/1074> cat .kshrc
#sccs	"@(#)install:.kshrc	1.1"

set -ao gmacs

ttyname=$(tty)
HISTFILE=$HOME/.kshist-${ttyname##*/};export HISTFILE
HISTSIZE=128;export HISTSIZE
# > $HISTFILE

MORE=-c
PATH=$PATH
PS1=`/usr/local/bin/kshpr`
PS2="ksh +> "
PS3=":> "
EDITOR=/usr/local/bin/emacs
FCEDIT=/usr/local/bin/emacs
VISUAL=/usr/local/bin/emacs
ksh 1073/1074> 
ksh 1073/1074> cat /usr/local/src/kshpr/kshpr.c
/*	kshpr
 *
 *	This program displays my idea of a ksh prompt that is different for a
 *	normal user than it is for a su'd user.
 *
 *	The intent is for this program to be run in a .kshrc script per:
 *
 *		PS1=`/usr/local/bin/kshpr`
 *
 *	The normal output is:  "ksh $PPID/$$> ", and
 *	the output if su'd is: "ksh-su $PPID/$$# "
 *
 *	Thad Floryan, 3-June-1989
 */

#include <stdio.h>

extern int getuid();

main()
{
	if (getuid() == 0) fprintf(stdout, "ksh-su $PPID/$$# ");
	else               fprintf(stdout, "ksh $PPID/$$> ");
}
ksh 1073/1074> 
ksh 1073/1074> cat /usr/local/src/kshpr/Makefile
# Makefile for kshpr

CC=	gcc
CFLAGS=	-O

kshpr:		kshpr.o
		ld /lib/crt0s.o /lib/shlib.ifile kshpr.o -o kshpr -s
		rm kshpr.o

kshpr.o:	kshpr.c
		$(CC) $(CFLAGS) -c kshpr.c
ksh 1073/1074>