VISUAL/EDITOR = emacs in ksh

Thad P Floryan thad at cup.portal.com
Thu Dec 14 22:15:56 AEST 1989


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 at 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> 



More information about the Unix-pc.general mailing list