🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
4 messages
4 total messages Started by Peter Mielke Sun, 21 Oct 1990 22:01
Re: Questions about rewriting the History function.
#1077
Author: Peter Mielke
Date: Sun, 21 Oct 1990 22:01
49 lines
2016 bytes
In <1990Oct19.165721.7584@polyof.poly.edu>, mhoffman@george.poly.edu writes:
> 
> I am working on a senior project to rewrite the history function for
> UNIX. My goal is to have the new history functon work like it does in
> MS_DOS.  i.e. I want to be able to call up past commands and edit them
> by using the control <hjkl> characters. Additionally, I would like to
> write this as a stand alone program so that I do not have to rewrite
> the shell.
> 

If you are in the csh you don't have to write such a creature, one
already exists:

----------cut here------------
# Edit history list at line containing last command (open mode).
# Get up to 22 most recent commands.
# To work properly, put in .login:  alias r source /usr/local/bin/redo
# Author unknown.
# history -h 22 >! /tmp/redo.$$
#
history -h 22 | grep -v '^r$' >! /tmp/redo.$$
#
# Make CR map to :wq! and start ex quietly at 2nd to last line in open mode.
# ex - '+map 
ex - '+map 
#
# have to show output so tty works
#
# 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) !!
----------cut here------------
--
Peter Mielke                     Preferred ->  psmielke@lotus.UWaterloo.ca
University of Waterloo                         peter@doe.utoronto.ca
An undergrad that's been around too long...
Re: Questions about rewriting the History function.
#1079
Author: Ti Kan
Date: Tue, 23 Oct 1990 23:34
26 lines
1831 bytes
In <1990Oct19.165721.7584@polyof.poly.edu>, mhoffman@george.poly.edu writes:
> 
> I am working on a senior project to rewrite the history function for
> UNIX. My goal is to have the new history functon work like it does in
> MS_DOS.  i.e. I want to be able to call up past commands and edit them
> by using the control <hjkl> characters. Additionally, I would like to
> write this as a stand alone program so that I do not have to rewrite
> the shell.

Perhaps it is useful to you to write such a thing for your senior
project, but it seems like such a waste of effort when you can
just use ksh (Korn Shell) that already has command history editing
capability.

Anyway, this will be difficult without incorporating the functionality
into the shell.  You can't really intercept keyboard input with a user
program before the shell gets it, unless you have a really weird
tty driver.  Also, how do you distinguish shell commands from
keystrokes typed during the run of an application?

-Ti
-- 
Ti Kan | vorsprung durch technik!                                       \\\
Internet: ti@altos.com                                                   \\\
UUCP: ...!{sun|sco|pyramid|amdahl|uunet}!altos!ti                     /// \\\
The opinions herein are not necessarily those of Altos.              ////////\
Re: Questions about rewriting the History function.
#1146
Author: Michael Meissner
Date: Wed, 31 Oct 1990 23:21
32 lines
2164 bytes
In article <4288@altos86.Altos.COM> ti@altos86.Altos.COM (Ti Kan)
writes:

| In <1990Oct19.165721.7584@polyof.poly.edu>, mhoffman@george.poly.edu writes:
| > 
| > I am working on a senior project to rewrite the history function for
| > UNIX. My goal is to have the new history functon work like it does in
| > MS_DOS.  i.e. I want to be able to call up past commands and edit them
| > by using the control <hjkl> characters. Additionally, I would like to
| > write this as a stand alone program so that I do not have to rewrite
| > the shell.

	...

| Anyway, this will be difficult without incorporating the functionality
| into the shell.  You can't really intercept keyboard input with a user
| program before the shell gets it, unless you have a really weird
| tty driver.  Also, how do you distinguish shell commands from
| keystrokes typed during the run of an application?

Actually on BSD systems, it is somewhat straight forward.  You make
the history function be a pty master, and spawn the shell with the
slave pty as it's /dev/tty.  In fact's it was submitted to the
moderated group comp.sources.unix about 1-2 years ago.  Remember that
UNIX is not the same thing on all platforms -- if your system doesn't
have a useful feature, it doesn't necessarily mean that my system must
not have that feature.....
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?
Re: Questions about rewriting the History function.
#1161
Author: Dan Bernstein
Date: Fri, 02 Nov 1990 19:30
12 lines
1080 bytes
In article <MEISSNER.90Oct31182112@osf.osf.org> meissner@osf.org (Michael Meissner) writes:
> Actually on BSD systems, it is somewhat straight forward.  You make
> the history function be a pty master, and spawn the shell with the
> slave pty as it's /dev/tty.

It's now exceedingly straightforward, as the ``pty'' program will handle
all the details of pseudo-terminal allocation and management. See
pmlined, just posted to alt.sources, for an example of how easy it is to
implement a line discipline using pty. Feel free to play with pmlined
and add features.

---Dan
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads