9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] tab completion and command history in rc
@ 2005-11-04  4:27 YAMANASHI Takeshi
  2005-11-04  5:28 ` Ronald G Minnich
  0 siblings, 1 reply; 39+ messages in thread
From: YAMANASHI Takeshi @ 2005-11-04  4:27 UTC (permalink / raw)
  To: 9fans

> While I was looking into win src to see how easy it is
> to let it learn to output to +Errors window

It turned out to be easy to do a first rough attempt.
You can download main.c into /acme/bin/source/win,
mk and run as "/somewhere/win -m".
	http://p9c.cc.titech.ac.jp/plan9/tmp/main.c
-- 
"on travel, off the network ... and a fossil in my pocket"




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  5:28 ` Ronald G Minnich
@ 2005-11-04  4:41   ` Matthew J. Sottile
  2005-11-04  5:26   ` Jack Johnson
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 39+ messages in thread
From: Matthew J. Sottile @ 2005-11-04  4:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs


> On Linux, I find myself trying to mouse into the middle of a window and
> type text; and of course there's all the other Plan 9 bits you don't get
> on Unix that you miss a lot. I pound the keyboard a lot. I go through a
> lot of keyboards. One advantage of buying clusters is you have lots of
> keyboards lying around.

He's not lying.  I'm right next door and occasionally feel rather sorry
for the poor devices... ;)

-m

---
Matthew Sottile (matt@lanl.gov)
Advanced Computing Laboratory (CCS-1)
Los Alamos National Laboratory
Los Alamos, NM 87545
Phone: (505)665-6057



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  5:28 ` Ronald G Minnich
  2005-11-04  4:41   ` Matthew J. Sottile
@ 2005-11-04  5:26   ` Jack Johnson
  2005-11-04  8:50   ` lucio
  2005-11-04 15:06   ` erik quanstrom
  3 siblings, 0 replies; 39+ messages in thread
From: Jack Johnson @ 2005-11-04  5:26 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 11/3/05, Ronald G Minnich <rminnich@lanl.gov> wrote:
> I don't think that rc and the rio interface and all that are the be-all
> and end-all of interfaces. Neither are X11, Emacs, and bash. It's all a
> work in progress, all the time. There are features from each I miss on
> the other.

I've been using a Mac for about six months now, and found that I've
accidentally become an Exposé addict.  Just today I was at work with
way too many windows open, trying to work on one project while my boss
was instant messaging me about some other project, and I flung my
cursor into the upper-right corner, waited three seconds and started
muttering, "What the HELL?!?" before I realized that Windows was not
going to comply with my gesture.

Keeping mouse buttons straight between X, PuTTY, rio, acme, CMD, etc.,
context sensitivities among command/control key options in Aqua, GNOME
and Windows, and command-line parameters between Plan 9, GNU and MS is
enough to drive a person crazy.  I may have chortled a bit too
gleefully at Takeshi's button-3 mishap, laughing not just at him but
with him.

I think I have the most respect for Russ, apparently navigating X,
Qt/GTK+, acme and rio apps simultaneously on a regular basis.  But
perhaps he's still young enough that the hair grows back. :)

-Jack


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  4:27 [9fans] tab completion and command history in rc YAMANASHI Takeshi
@ 2005-11-04  5:28 ` Ronald G Minnich
  2005-11-04  4:41   ` Matthew J. Sottile
                     ` (3 more replies)
  0 siblings, 4 replies; 39+ messages in thread
From: Ronald G Minnich @ 2005-11-04  5:28 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I don't think that rc and the rio interface and all that are the be-all 
and end-all of interfaces. Neither are X11, Emacs, and bash. It's all a 
work in progress, all the time. There are features from each I miss on 
the other.

On Linux, I find myself trying to mouse into the middle of a window and 
type text; and of course there's all the other Plan 9 bits you don't get 
on Unix that you miss a lot. I pound the keyboard a lot. I go through a 
lot of keyboards. One advantage of buying clusters is you have lots of 
keyboards lying around.

I get really annoyed that up and down arrow act very differently than 
right and left arrow in acme. I get annoyed that acme is focus follows 
mouse, and rio is not (well, andrey built me a rio with focus follows 
mouse for linux, and I love it).  On Plan 9, I still miss command 
history that spans instances of the shell. Sorry, that's not "Plan 9 
PC", but it's my preference.

So, Rian, if there's stuff you find you miss on Plan 9, it may be you 
have not learned a "Plan 9" way to do things, or it may be that Plan 9 
environment is lacking in some way. I think many of us take a guilty 
pleasure in ^F. I know I do. What else might we like from the unix world 
that we don't talk about? It would be interesting to see.

ron


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  5:28 ` Ronald G Minnich
  2005-11-04  4:41   ` Matthew J. Sottile
  2005-11-04  5:26   ` Jack Johnson
@ 2005-11-04  8:50   ` lucio
  2005-11-04 15:06   ` erik quanstrom
  3 siblings, 0 replies; 39+ messages in thread
From: lucio @ 2005-11-04  8:50 UTC (permalink / raw)
  To: 9fans

> So, Rian, if there's stuff you find you miss on Plan 9, it may be you 
> have not learned a "Plan 9" way to do things, or it may be that Plan 9 
> environment is lacking in some way. I think many of us take a guilty 
> pleasure in ^F. I know I do. What else might we like from the unix world 
> that we don't talk about? It would be interesting to see.

A list on the wiki would not go amiss.  No harm in a bit of
objectivity and soul searching.

In passing, it's great news that VESA and a new VM are about to
happen, shows that in important places Plan 9 is still significant
enough to assign valuable resources to.

But, as Ron points out, Plan 9 has its own "True Way (TM)" that
occasionally puts a huge spanner in the works.

One of my gripes is the PC keyboard.  I haven't a clue what
contorsions the kernel goes through to provide the final product, but
the end result is not what I would ask for.  For example, the <Scroll
Lock><Scroll Lock> tap is used to switch the "console" on a two-way
switch I'm using: that generates two Peter faces in Plan 9.  Wrong?
Maybe not, but it's too different to be declared exemplary.

And for all that using the mouse is demonstrated to be faster, as long
as mouse _and_ keyboard are both in use, I think pulling one's hands
off the keyboard to re-position the cursor is a silly necessity (as
demonstrated by the introduction of cursor-right and cursor-left
keys).

Now let me go look at hiding that fat arrow out of the way while I
type with both hands.

++L



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  5:28 ` Ronald G Minnich
                     ` (2 preceding siblings ...)
  2005-11-04  8:50   ` lucio
@ 2005-11-04 15:06   ` erik quanstrom
  2005-11-04 15:24     ` Axel Belinfante
                       ` (3 more replies)
  3 siblings, 4 replies; 39+ messages in thread
From: erik quanstrom @ 2005-11-04 15:06 UTC (permalink / raw)
  To: 9fans, Ronald G Minnich

Ronald G Minnich <rminnich@lanl.gov> writes

| [...]  On Plan 9, I still miss command 
| history that spans instances of the shell. Sorry, that's not "Plan 9 
| PC", but it's my preference.

global /persisitant/ history is a "must have" for me. it was the reason
i utf-8ized byron's (unmaintained?) shell. 

productivity will suffer just a little bit if you have to retype something
as a last resort. but trying to figure out that ip address you ssh'd to last 
week/month/year could waste 10 minutes. grepping persistant history is a 
big win for me.

(if you want global but non-persistant history on p9p changing the " command to look at
all your open windows wouldn't be too hard but you would have an ordering
problem; it would difficult to order the commands correctly.)

i looked at modifying rc to write commands to a history file but it
didn't seem to fit very well. maybe a hook would be better as in

fn post-cmd {
	echo $* >> $history
}

paul haahr's shell es went all the way and made the whole interactive loop a function.

erik


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 15:06   ` erik quanstrom
@ 2005-11-04 15:24     ` Axel Belinfante
  2005-11-04 15:29       ` erik quanstrom
  2005-11-04 15:26     ` Charles Forsyth
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 39+ messages in thread
From: Axel Belinfante @ 2005-11-04 15:24 UTC (permalink / raw)
  To: erik quanstrom, Fans of the OS Plan 9 from Bell Labs

> paul haahr's shell es went all the way and
> made the whole interactive loop a function.

Still using es on unix (with p9p) and
loving its persistent history
(even though my history file is now 5+ Mb)

Axel.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 15:06   ` erik quanstrom
  2005-11-04 15:24     ` Axel Belinfante
@ 2005-11-04 15:26     ` Charles Forsyth
  2005-11-04 15:54       ` erik quanstrom
  2005-11-04 16:27     ` Russ Cox
  2005-11-05  8:54     ` Scott Schwartz
  3 siblings, 1 reply; 39+ messages in thread
From: Charles Forsyth @ 2005-11-04 15:26 UTC (permalink / raw)
  To: 9fans

> i looked at modifying rc to write commands to a history file but it
> didn't seem to fit very well. maybe a hook would be better as in

why not have rio log what you type, or put something between
your keyboard and rio?



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 15:24     ` Axel Belinfante
@ 2005-11-04 15:29       ` erik quanstrom
  0 siblings, 0 replies; 39+ messages in thread
From: erik quanstrom @ 2005-11-04 15:29 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs, Axel Belinfante

yup. byron's rc will do the same thing. i've lost my history
file a few times but i still have ~10M of it. history still performs
well enough not to notice.

erik

Axel Belinfante <Axel.Belinfante@cs.utwente.nl> writes

| 
| > paul haahr's shell es went all the way and
| > made the whole interactive loop a function.
| 
| Still using es on unix (with p9p) and
| loving its persistent history
| (even though my history file is now 5+ Mb)
| 
| Axel.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 15:26     ` Charles Forsyth
@ 2005-11-04 15:54       ` erik quanstrom
  2005-11-05  9:20         ` Charles Forsyth
  0 siblings, 1 reply; 39+ messages in thread
From: erik quanstrom @ 2005-11-04 15:54 UTC (permalink / raw)
  To: 9fans, Charles Forsyth

i thought about that. it really seems like the "right" solution in
once sense. it moves history completely out of the purview of 
the shell. the bonus is that you would have history for every application.

the downside is that you would have history for every application. that's
explicitly not what i want. the input to ed/sam -d editing sessions interleaved
with mail and rc commands doesn't seem very useful to me.

rio thus "feels" to me like the wrong level at which to implement this 
functionality.

to summarize:

a. rio doesn't know if the input is an rc command or input to, say, sam -d.

b. it would be nice to improve on the old history mechanism; rio doesn't have
enough information to do this. e.g.

	1. syntax errors shouldn't be logged to the history
	2. multiline statements should be recalled as a unit.

for me (a) would be a big problem. (b) hasn't been solved in a
decade, so i guess i can live with it. ;-)

- erik

Charles Forsyth <forsyth@terzarima.net> writes

| 
| > i looked at modifying rc to write commands to a history file but it
| > didn't seem to fit very well. maybe a hook would be better as in
| 
| why not have rio log what you type, or put something between
| your keyboard and rio?


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 15:06   ` erik quanstrom
  2005-11-04 15:24     ` Axel Belinfante
  2005-11-04 15:26     ` Charles Forsyth
@ 2005-11-04 16:27     ` Russ Cox
  2005-12-09  1:58       ` erik quanstrom
  2005-11-05  8:54     ` Scott Schwartz
  3 siblings, 1 reply; 39+ messages in thread
From: Russ Cox @ 2005-11-04 16:27 UTC (permalink / raw)
  To: erik quanstrom, Fans of the OS Plan 9 from Bell Labs

> i looked at modifying rc to write commands to a history file but it
> didn't seem to fit very well. maybe a hook would be better as in

it's not hard.  perhaps you object to rc's reformatting of
what you typed?

diff -c ./exec.c h/exec.c
./exec.c:9,14 - h/exec.c:9,16
  #include "exec.h"
  #include "io.h"
  #include "fns.h"
+
+ tree *line;
  /*
   * Start executing the given code at the given pc with the given redirection
   */
./exec.c:112,118 - h/exec.c:114,120
  {
  	code bootstrap[32];
  	char num[12], *rcmain;
- 	int i;
+ 	int i, fd;
  	
  	/* needed for rcmain later */
  	putenv("PLAN9", unsharp("#9"));
./exec.c:123,128 - h/exec.c:125,132
  	if(flag['I']) flag['i'] = 0;
  	else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset;
  	rcmain=flag['m']?flag['m'][0]:Rcmain();
+ 	if((fd = open("/tmp/history", OWRITE)) >= 0)
+ 		history=openfd(fd);
  	err=openfd(2);
  	kinit();
  	Trapinit();
./exec.c:773,778 - h/exec.c:777,788
  		}
  	}
  	else{
+ 		if(p->iflag && history && line){
+ 			char buf[30];
+ 			strcpy(buf, ctime(time(0)));
+ 			buf[28] = 0;
+ 			pfmt(history, "%s %t\n", buf, line);
+ 		}
  		ntrap = 0;	/* avoid double-interrupts during blocked writes */
  		--p->pc;	/* re-execute Xrdcmds after codebuf runs */
  		start(codebuf, 1, runq->local);
diff -c ./io.h h/io.h
./io.h:11,16 - h/io.h:11,17
  	char *bufp, *ebuf, *strp, buf[NBUF];
  };
  io *err;
+ io *history;
  io *openfd(int), *openstr(void), *opencore(char *, int);
  int emptybuf(io*);
  void pchr(io*, int);
diff -c ./rc.h h/rc.h
./rc.h:143,145 - h/rc.h:143,146
  int lastc;
  int lastword;
  int kidpid;
+ extern tree *line;
diff -c ./syn.y h/syn.y
./syn.y:21,28 - h/syn.y:21,28
  %type<tree> NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN
  %type<tree> WORD REDIR DUP PIPE
  %%
- rc:				{ return 1;}
- |	line '\n'		{return !compile($1);}
+ rc:				{ line = nil; return 1;}
+ |	line '\n'		{ line = $1; return !compile($1);}
  line:	cmd
  |	cmdsa line		{$$=tree2(';', $1, $2);}
  body:	cmd


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 15:06   ` erik quanstrom
                       ` (2 preceding siblings ...)
  2005-11-04 16:27     ` Russ Cox
@ 2005-11-05  8:54     ` Scott Schwartz
  2005-11-05 12:13       ` erik quanstrom
  2005-11-05 16:01       ` Ronald G Minnich
  3 siblings, 2 replies; 39+ messages in thread
From: Scott Schwartz @ 2005-11-05  8:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

| global /persisitant/ history is a "must have" for me.
 
I have to agree--it's a great feature.  But one might argue that you
want global persistant tty input even more, so it's rio that ought to
be recording what you've typed.  


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 15:54       ` erik quanstrom
@ 2005-11-05  9:20         ` Charles Forsyth
  0 siblings, 0 replies; 39+ messages in thread
From: Charles Forsyth @ 2005-11-05  9:20 UTC (permalink / raw)
  To: 9fans

> i thought about that. it really seems like the "right" solution in
> once sense. it moves history completely out of the purview of 
> the shell. the bonus is that you would have history for every application.
> 
> the downside is that you would have history for every application. that's
> explicitly not what i want. the input to ed/sam -d editing sessions interleaved
> with mail and rc commands doesn't seem very useful to me.

i was thinking of something along the lines of reactive keyboard, or better;
something that adapts to your context.  if u cn rd ths u shd gt a btr fon



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-05  8:54     ` Scott Schwartz
@ 2005-11-05 12:13       ` erik quanstrom
  2005-11-05 16:01       ` Ronald G Minnich
  1 sibling, 0 replies; 39+ messages in thread
From: erik quanstrom @ 2005-11-05 12:13 UTC (permalink / raw)
  To: 9fans, Scott Schwartz

script(1) already does what you suggest on linux for 1 termanal.
but it's definately not what i want.

what utility would the saved text be? i think rio's editing
features would make it very hard to decipher.

- erik

Scott Schwartz <schwartz@bio.cse.psu.edu> writes

| 
| | global /persisitant/ history is a "must have" for me.
|  
| I have to agree--it's a great feature.  But one might argue that you
| want global persistant tty input even more, so it's rio that ought to
| be recording what you've typed.  


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-05  8:54     ` Scott Schwartz
  2005-11-05 12:13       ` erik quanstrom
@ 2005-11-05 16:01       ` Ronald G Minnich
  1 sibling, 0 replies; 39+ messages in thread
From: Ronald G Minnich @ 2005-11-05 16:01 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Scott Schwartz wrote:
> | global /persisitant/ history is a "must have" for me.
>  
> I have to agree--it's a great feature.  But one might argue that you
> want global persistant tty input even more, so it's rio that ought to
> be recording what you've typed.  

on the amiga, in the later days, it was in the windowing system as well.

I don't recall how it all worked, but all console apps got history IIRC.

ron


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04 16:27     ` Russ Cox
@ 2005-12-09  1:58       ` erik quanstrom
  0 siblings, 0 replies; 39+ messages in thread
From: erik quanstrom @ 2005-12-09  1:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs, Russ Cox

nope, i didn't object to the reformatting. due to the snow here i was stuck
for a couple of hrs with an ancient copy of p9p and decided to have another go
at the problem because i wanted history tied to a variable. i came up with this:

- erik

btw: is there any way to simulate byron's ``(new-ifs-list) {cmd} with rc?
for example:
	fu=x
	fn fu {echo x}
	nl = '
'
	for(i in ``$nl {whatis fu}) echo $i

	fu=x
	fn fn {echo x}

; rcsdiff syn.y
===================================================================
RCS file: RCS/syn.y,v
retrieving revision 1.1
diff -r1.1 syn.y
25c25,28
< |	line '\n'		{return !compile($1);}
---
> |	line '\n'			{ int i = !compile($1); 
> 				if (!i) 
> 					whistory($1); 
> 				return i;}
; cat history.c
// feel free to roll your eyes.

#include "rc.h"
#include "exec.h"
#include "fns.h"
#include "io.h"

void
whistory(tree* t){
	var* v;
	char* s;
	int fd;
	io* o;
	int flags = OAPPEND|OWRITE;

	if (!runq->iflag || !t)
		return;

	v = vlook("history");
	if (!v->val || 1 != count(v->val))
		return;

	if (v->fn)
		return;	// future: fn history {echo $*>>$history_file}

	s = v->val->word;
	if((fd=open(s, flags))<0 && (fd=create(s, flags, 0666L))<0){
		//setvar("history", 0);
 		return;
	}
	
	o = openfd(fd);
	pfmt(o, "%t\n", t);
	closeio(o);
}

Russ Cox <rsc@swtch.com> writes

| 
| > i looked at modifying rc to write commands to a history file but it
| > didn't seem to fit very well. maybe a hook would be better as in
| 
| it's not hard.  perhaps you object to rc's reformatting of
| what you typed?
| 
| diff -c ./exec.c h/exec.c
| ./exec.c:9,14 - h/exec.c:9,16
|   #include "exec.h"
|   #include "io.h"
|   #include "fns.h"
| +
| + tree *line;
|   /*
|    * Start executing the given code at the given pc with the given redirection
|    */
| ./exec.c:112,118 - h/exec.c:114,120
|   {
|   	code bootstrap[32];
|   	char num[12], *rcmain;
| - 	int i;
| + 	int i, fd;
|   	
|   	/* needed for rcmain later */
|   	putenv("PLAN9", unsharp("#9"));
| ./exec.c:123,128 - h/exec.c:125,132
|   	if(flag['I']) flag['i'] = 0;
|   	else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset;
|   	rcmain=flag['m']?flag['m'][0]:Rcmain();
| + 	if((fd = open("/tmp/history", OWRITE)) >= 0)
| + 		history=openfd(fd);
|   	err=openfd(2);
|   	kinit();
|   	Trapinit();
| ./exec.c:773,778 - h/exec.c:777,788
|   		}
|   	}
|   	else{
| + 		if(p->iflag && history && line){
| + 			char buf[30];
| + 			strcpy(buf, ctime(time(0)));
| + 			buf[28] = 0;
| + 			pfmt(history, "%s %t\n", buf, line);
| + 		}
|   		ntrap = 0;	/* avoid double-interrupts during blocked writes */
|   		--p->pc;	/* re-execute Xrdcmds after codebuf runs */
|   		start(codebuf, 1, runq->local);
| diff -c ./io.h h/io.h
| ./io.h:11,16 - h/io.h:11,17
|   	char *bufp, *ebuf, *strp, buf[NBUF];
|   };
|   io *err;
| + io *history;
|   io *openfd(int), *openstr(void), *opencore(char *, int);
|   int emptybuf(io*);
|   void pchr(io*, int);
| diff -c ./rc.h h/rc.h
| ./rc.h:143,145 - h/rc.h:143,146
|   int lastc;
|   int lastword;
|   int kidpid;
| + extern tree *line;
| diff -c ./syn.y h/syn.y
| ./syn.y:21,28 - h/syn.y:21,28
|   %type<tree> NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN
|   %type<tree> WORD REDIR DUP PIPE
|   %%
| - rc:				{ return 1;}
| - |	line '\n'		{return !compile($1);}
| + rc:				{ line = nil; return 1;}
| + |	line '\n'		{ line = $1; return !compile($1);}
|   line:	cmd
|   |	cmdsa line		{$$=tree2(';', $1, $2);}
|   body:	cmd
sendmail 9fans@cse.psu.edu
From: erik quanstrom <quanstro@quanstro.net>
Reply-To: erik quanstrom <quanstro@speakeasy.net>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>,
	Russ Cox <rsc@swtch.com>
References: <fc73b7d828b678708affd1677c1c022a@orthanc.cc.titech.ac.jp>
	<436AF189.2080909@lanl.gov>
	<20051104145056.A3EC1651A4@dexter-peak.quanstro.net>
	<ee9e417a0511040827i7f76d805y42199469f12b8c33@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
In-Reply-To: <ee9e417a0511040827i7f76d805y42199469f12b8c33@mail.gmail.com>
Subject: Re: [9fans] tab completion and command history in rc

nope, i didn't object to the reformatting. due to the snow here i was stuck
for a couple of hrs with an ancient copy of p9p and decided to have another go
at the problem because i wanted history tied to a variable. i came up with this:

- erik

btw: is there any way to simulate byron's ``(new-ifs-list) {cmd} with rc?
for example:
	fu=x
	fn fu {echo x}
	nl = '
'
	for(i in ``$nl {whatis fu}) echo $i

	fu=x
	fn fn {echo x}

; rcsdiff syn.y
===================================================================
RCS file: RCS/syn.y,v
retrieving revision 1.1
diff -r1.1 syn.y
25c25,28
< |	line '\n'		{return !compile($1);}
---
> |	line '\n'			{ int i = !compile($1); 
> 				if (!i) 
> 					whistory($1); 
> 				return i;}
; cat history.c
// feel free to roll your eyes.

#include "rc.h"
#include "exec.h"
#include "fns.h"
#include "io.h"

void
whistory(tree* t){
	var* v;
	char* s;
	int fd;
	io* o;
	int flags = OAPPEND|OWRITE;

	if (!runq->iflag || !t)
		return;

	v = vlook("history");
	if (!v->val || 1 != count(v->val))
		return;

	if (v->fn)
		return;	// future: fn history {echo $*>>$history_file}

	s = v->val->word;
	if((fd=open(s, flags))<0 && (fd=create(s, flags, 0666L))<0){
		//setvar("history", 0);
 		return;
	}
	
	o = openfd(fd);
	pfmt(o, "%t\n", t);
	closeio(o);
}

Russ Cox <rsc@swtch.com> writes

| 
| > i looked at modifying rc to write commands to a history file but it
| > didn't seem to fit very well. maybe a hook would be better as in
| 
| it's not hard.  perhaps you object to rc's reformatting of
| what you typed?
| 
| diff -c ./exec.c h/exec.c
| ./exec.c:9,14 - h/exec.c:9,16
|   #include "exec.h"
|   #include "io.h"
|   #include "fns.h"
| +
| + tree *line;
|   /*
|    * Start executing the given code at the given pc with the given redirection
|    */
| ./exec.c:112,118 - h/exec.c:114,120
|   {
|   	code bootstrap[32];
|   	char num[12], *rcmain;
| - 	int i;
| + 	int i, fd;
|   	
|   	/* needed for rcmain later */
|   	putenv("PLAN9", unsharp("#9"));
| ./exec.c:123,128 - h/exec.c:125,132
|   	if(flag['I']) flag['i'] = 0;
|   	else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset;
|   	rcmain=flag['m']?flag['m'][0]:Rcmain();
| + 	if((fd = open("/tmp/history", OWRITE)) >= 0)
| + 		history=openfd(fd);
|   	err=openfd(2);
|   	kinit();
|   	Trapinit();
| ./exec.c:773,778 - h/exec.c:777,788
|   		}
|   	}
|   	else{
| + 		if(p->iflag && history && line){
| + 			char buf[30];
| + 			strcpy(buf, ctime(time(0)));
| + 			buf[28] = 0;
| + 			pfmt(history, "%s %t\n", buf, line);
| + 		}
|   		ntrap = 0;	/* avoid double-interrupts during blocked writes */
|   		--p->pc;	/* re-execute Xrdcmds after codebuf runs */
|   		start(codebuf, 1, runq->local);
| diff -c ./io.h h/io.h
| ./io.h:11,16 - h/io.h:11,17
|   	char *bufp, *ebuf, *strp, buf[NBUF];
|   };
|   io *err;
| + io *history;
|   io *openfd(int), *openstr(void), *opencore(char *, int);
|   int emptybuf(io*);
|   void pchr(io*, int);
| diff -c ./rc.h h/rc.h
| ./rc.h:143,145 - h/rc.h:143,146
|   int lastc;
|   int lastword;
|   int kidpid;
| + extern tree *line;
| diff -c ./syn.y h/syn.y
| ./syn.y:21,28 - h/syn.y:21,28
|   %type<tree> NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN
|   %type<tree> WORD REDIR DUP PIPE
|   %%
| - rc:				{ return 1;}
| - |	line '\n'		{return !compile($1);}
| + rc:				{ line = nil; return 1;}
| + |	line '\n'		{ line = $1; return !compile($1);}
|   line:	cmd
|   |	cmdsa line		{$$=tree2(';', $1, $2);}
|   body:	cmd
sendmail 9fans@cse.psu.edu
From: erik quanstrom <quanstro@quanstro.net>
Reply-To: erik quanstrom <quanstro@speakeasy.net>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>,
	Russ Cox <rsc@swtch.com>
References: <fc73b7d828b678708affd1677c1c022a@orthanc.cc.titech.ac.jp>
	<436AF189.2080909@lanl.gov>
	<20051104145056.A3EC1651A4@dexter-peak.quanstro.net>
	<ee9e417a0511040827i7f76d805y42199469f12b8c33@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
In-Reply-To: <ee9e417a0511040827i7f76d805y42199469f12b8c33@mail.gmail.com>
Subject: Re: [9fans] tab completion and command history in rc

nope, i didn't object to the reformatting. due to the snow here i was stuck
for a couple of hrs with an ancient copy of p9p and decided to have another go
at the problem because i wanted history tied to a variable. i came up with this:

- erik

btw: is there any way to simulate byron's ``(new-ifs-list) {cmd} with rc?
for example:
	fu=x
	fn fu {echo x}
	nl = '
'
	for(i in ``$nl {whatis fu}) echo $i

	fu=x
	fn fn {echo x}

; rcsdiff syn.y
===================================================================
RCS file: RCS/syn.y,v
retrieving revision 1.1
diff -r1.1 syn.y
25c25,28
< |	line '\n'		{return !compile($1);}
---
> |	line '\n'			{ int i = !compile($1); 
> 				if (!i) 
> 					whistory($1); 
> 				return i;}
; cat history.c
// feel free to roll your eyes.

#include "rc.h"
#include "exec.h"
#include "fns.h"
#include "io.h"

void
whistory(tree* t){
	var* v;
	char* s;
	int fd;
	io* o;
	int flags = OAPPEND|OWRITE;

	if (!runq->iflag || !t)
		return;

	v = vlook("history");
	if (!v->val || 1 != count(v->val))
		return;

	if (v->fn)
		return;	// future: fn history {echo $*>>$history_file}

	s = v->val->word;
	if((fd=open(s, flags))<0 && (fd=create(s, flags, 0666L))<0){
		//setvar("history", 0);
 		return;
	}
	
	o = openfd(fd);
	pfmt(o, "%t\n", t);
	closeio(o);
}

Russ Cox <rsc@swtch.com> writes

| 
| > i looked at modifying rc to write commands to a history file but it
| > didn't seem to fit very well. maybe a hook would be better as in
| 
| it's not hard.  perhaps you object to rc's reformatting of
| what you typed?
| 
| diff -c ./exec.c h/exec.c
| ./exec.c:9,14 - h/exec.c:9,16
|   #include "exec.h"
|   #include "io.h"
|   #include "fns.h"
| +
| + tree *line;
|   /*
|    * Start executing the given code at the given pc with the given redirection
|    */
| ./exec.c:112,118 - h/exec.c:114,120
|   {
|   	code bootstrap[32];
|   	char num[12], *rcmain;
| - 	int i;
| + 	int i, fd;
|   	
|   	/* needed for rcmain later */
|   	putenv("PLAN9", unsharp("#9"));
| ./exec.c:123,128 - h/exec.c:125,132
|   	if(flag['I']) flag['i'] = 0;
|   	else if(flag['i']==0 && argc==1 && Isatty(0)) flag['i'] = flagset;
|   	rcmain=flag['m']?flag['m'][0]:Rcmain();
| + 	if((fd = open("/tmp/history", OWRITE)) >= 0)
| + 		history=openfd(fd);
|   	err=openfd(2);
|   	kinit();
|   	Trapinit();
| ./exec.c:773,778 - h/exec.c:777,788
|   		}
|   	}
|   	else{
| + 		if(p->iflag && history && line){
| + 			char buf[30];
| + 			strcpy(buf, ctime(time(0)));
| + 			buf[28] = 0;
| + 			pfmt(history, "%s %t\n", buf, line);
| + 		}
|   		ntrap = 0;	/* avoid double-interrupts during blocked writes */
|   		--p->pc;	/* re-execute Xrdcmds after codebuf runs */
|   		start(codebuf, 1, runq->local);
| diff -c ./io.h h/io.h
| ./io.h:11,16 - h/io.h:11,17
|   	char *bufp, *ebuf, *strp, buf[NBUF];
|   };
|   io *err;
| + io *history;
|   io *openfd(int), *openstr(void), *opencore(char *, int);
|   int emptybuf(io*);
|   void pchr(io*, int);
| diff -c ./rc.h h/rc.h
| ./rc.h:143,145 - h/rc.h:143,146
|   int lastc;
|   int lastword;
|   int kidpid;
| + extern tree *line;
| diff -c ./syn.y h/syn.y
| ./syn.y:21,28 - h/syn.y:21,28
|   %type<tree> NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN
|   %type<tree> WORD REDIR DUP PIPE
|   %%
| - rc:				{ return 1;}
| - |	line '\n'		{return !compile($1);}
| + rc:				{ line = nil; return 1;}
| + |	line '\n'		{ line = $1; return !compile($1);}
|   line:	cmd
|   |	cmdsa line		{$$=tree2(';', $1, $2);}
|   body:	cmd


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:14 ` John Floren
                     ` (3 preceding siblings ...)
  2005-11-04  9:02   ` Scott Schwartz
@ 2005-11-04 15:13   ` "Nils O. Selåsdal"
  4 siblings, 0 replies; 39+ messages in thread
From: "Nils O. Selåsdal" @ 2005-11-04 15:13 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

John Floren wrote:

> 
> Ouch.  You seem to have unconsciously hit on some of the more hot-button
> topics for Plan 9 users.  Tab completion is partly implemented; hit
> "Ctrl-f".  However, as a quick foray onto #plan9 will tell you, nobody
> seems to believe in tab completion, finding multiple "ls" commands and
> copy-pasting to be faster.  As for command history, you are expected to
> find the previous command in your rc window, edit it, copy it, paste it
> to the prompt, and then run it.  This is obviously more efficient than
> hitting the "up" arrow.
Well, if you're just going to execute the same command again, 'up' can
be great. More often than not you're going to edit the command slightly,
in which case just point and click/mark with the mouse to edit and about 
3 mouse clicks to run it can be faster than it sounds - and in many 
cases faster than various keyboard gymnastics to get to the same point 
you're going to edit. This is my experience atleast.
If you have to poke around pages of output to find the last command,
this isn't that great though.

So both approaches has their strengths and flaws.
Merge them.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  2:08     ` Skip Tavakkolian
@ 2005-11-04  9:20       ` William Staniewicz
  0 siblings, 0 replies; 39+ messages in thread
From: William Staniewicz @ 2005-11-04  9:20 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

I agree this would be very helpful not only for instructional purposes
but to show off some of the features of plan9. Add captions and
narration and it is very handy.

 On 11/4/05, Skip Tavakkolian <9nut@9netics.com> wrote:
>
> > Edit any line in your window, double click at the start or end of the
> > line to select it, and then Middle-click->Send; is a very common and
> > useful idiom(note that in the default profile your shell prompt is
> > defined as a NOP function precisely for this).
>
> somebody should make a video of typical operations in
> rio and acme and put it on sources.
>
>

[-- Attachment #2: Type: text/html, Size: 922 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:14 ` John Floren
                     ` (2 preceding siblings ...)
  2005-11-04  1:23   ` Paul Lalonde
@ 2005-11-04  9:02   ` Scott Schwartz
  2005-11-04 15:13   ` "Nils O. Selåsdal"
  4 siblings, 0 replies; 39+ messages in thread
From: Scott Schwartz @ 2005-11-04  9:02 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

| As for command history, you are expected to
| find the previous command in your rc window, edit it, copy it, paste it
| to the prompt, and then run it.  This is obviously more efficient than
| hitting the "up" arrow.

Don't forget, you can grep the text of the window!  
If your prompt is distinctive, you're done.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
       [not found]     ` <000001c5e0e1$76791f80$14aaa8c0@utelsystems.local>
@ 2005-11-04  6:58       ` Nils O. Selåsdal
  0 siblings, 0 replies; 39+ messages in thread
From: Nils O. Selåsdal @ 2005-11-04  6:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, 2005-11-04 at 02:45 +0100, Uriel wrote:
> One last note: one of the reasons why tab-completion is frowned upon is
> because it's indication of too intricate paths, remember to keep your
> file trees clean and simple and to take advantage of binds and union
> mounts to keep everything at hand. If you do this you won't miss
> tab-completion and you will have a much easier time finding what you are
> looking for.

Even all simple paths arn't remembered, and it may still fewer
keystrokes.




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
       [not found] <000201c5e0e5$bbd617f0$14aaa8c0@utelsystems.local>
@ 2005-11-04  6:46 ` Nils O. Selåsdal
  0 siblings, 0 replies; 39+ messages in thread
From: Nils O. Selåsdal @ 2005-11-04  6:46 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, 2005-11-04 at 03:16 +0100, Skip Tavakkolian wrote:
> > Edit any line in your window, double click at the start or end of the
> > line to select it, and then Middle-click->Send; is a very common and
> > useful idiom(note that in the default profile your shell prompt is
> > defined as a NOP function precisely for this).
> 
> somebody should make a video of typical operations in
> rio and acme and put it on sources.

Would be great.
Do you voulenteer ?




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
@ 2005-11-04  4:01 YAMANASHI Takeshi
  0 siblings, 0 replies; 39+ messages in thread
From: YAMANASHI Takeshi @ 2005-11-04  4:01 UTC (permalink / raw)
  To: rsc, 9fans

Well, I strongly dis-recommend button-3'ing /dev/cons in acme. ;)

While I was looking into win src to see how easy it is
to let it learn to output to +Errors window, I mistakenly
clicked the path-which-not-to-be-mentioned.
-- 
"on travel, off the network ... and a fossil in my pocket"




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  3:42 YAMANASHI Takeshi
@ 2005-11-04  3:45 ` Russ Cox
  0 siblings, 0 replies; 39+ messages in thread
From: Russ Cox @ 2005-11-04  3:45 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Yes.  This method is almost there except that
> if you resize or move a directory window,
> the command "history" is gone. :)

Don't type in directory windows then... ;-)


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
@ 2005-11-04  3:42 YAMANASHI Takeshi
  2005-11-04  3:45 ` Russ Cox
  0 siblings, 1 reply; 39+ messages in thread
From: YAMANASHI Takeshi @ 2005-11-04  3:42 UTC (permalink / raw)
  To: 9fans

> I do this in acme a lot.  Type a command, ESC, b2 click.

Yes.  This method is almost there except that
if you resize or move a directory window,
the command "history" is gone. :)
-- 
"on travel, off the network ... and a fossil in my pocket"




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  2:30 YAMANASHI Takeshi
@ 2005-11-04  3:08 ` Russ Cox
  0 siblings, 0 replies; 39+ messages in thread
From: Russ Cox @ 2005-11-04  3:08 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 11/3/05, YAMANASHI Takeshi <9.nashi@gmail.com> wrote:
> > As for command history, you are expected to
> > find the previous command in your rc window, edit it, copy it, paste it
> > to the prompt, and then run it.  This is obviously more efficient than
> > hitting the "up" arrow.
> > As for keeping the command line always in view, mid-click on the window
> > and select "scroll".
>
> This reminded me of my old pet idea.  To ease finding the desired command
> in a window, how's it to split the window into two panes like sam does?
> I mean, you always enter commands in the command pane and every outputs will
> appear in the other output pane.
>
> In acme, you could achieve similar effect by typing commands in a directory
> window and the output appears in another "+Errors" window, but it's tiresome
> to Button-2'ing the command everytime.

I do this in acme a lot.  Type a command, ESC, b2 click.

Russ


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
@ 2005-11-04  2:30 YAMANASHI Takeshi
  2005-11-04  3:08 ` Russ Cox
  0 siblings, 1 reply; 39+ messages in thread
From: YAMANASHI Takeshi @ 2005-11-04  2:30 UTC (permalink / raw)
  To: 9fans

> As for command history, you are expected to
> find the previous command in your rc window, edit it, copy it, paste it
> to the prompt, and then run it.  This is obviously more efficient than
> hitting the "up" arrow.
> As for keeping the command line always in view, mid-click on the window
> and select "scroll".

This reminded me of my old pet idea.  To ease finding the desired command
in a window, how's it to split the window into two panes like sam does?
I mean, you always enter commands in the command pane and every outputs will
appear in the other output pane.

In acme, you could achieve similar effect by typing commands in a directory
window and the output appears in another "+Errors" window, but it's tiresome
to Button-2'ing the command everytime.
-- 
"on travel, off the network ... and a fossil in my pocket"




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:22   ` Uriel
  2005-11-04  1:27     ` Uriel
  2005-11-04  1:56     ` Rian Hunter
@ 2005-11-04  2:08     ` Skip Tavakkolian
  2005-11-04  9:20       ` William Staniewicz
       [not found]     ` <000001c5e0e1$76791f80$14aaa8c0@utelsystems.local>
  3 siblings, 1 reply; 39+ messages in thread
From: Skip Tavakkolian @ 2005-11-04  2:08 UTC (permalink / raw)
  To: 9fans

> Edit any line in your window, double click at the start or end of the
> line to select it, and then Middle-click->Send; is a very common and
> useful idiom(note that in the default profile your shell prompt is
> defined as a NOP function precisely for this).

somebody should make a video of typical operations in
rio and acme and put it on sources.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:27     ` Uriel
@ 2005-11-04  2:02       ` Russ Cox
  0 siblings, 0 replies; 39+ messages in thread
From: Russ Cox @ 2005-11-04  2:02 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> One last note: one of the reasons why tab-completion is frowned upon is
> because it's indication of too intricate paths, remember to keep your
> file trees clean and simple and to take advantage of binds and union
> mounts to keep everything at hand. If you do this you won't miss
> tab-completion and you will have a much easier time finding what you are
> looking for.

I don't buy this.  You can have a very simple path and still not remember
what a command is called.  I typed venti/^F the other day and was
annoyed that I didn't get a list of the venti programs.  So I typed
^U/bin/venti/^F and did get my list.  But there's a difference between
clean and easy to remember.

Russ


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
@ 2005-11-04  2:01 Federico G. Benavento
  0 siblings, 0 replies; 39+ messages in thread
From: Federico G. Benavento @ 2005-11-04  2:01 UTC (permalink / raw)
  To: 9fans

see: http://www.cs.bell-labs.com/wiki/plan9/Mouse_vs._keyboard

Federico G.Benavento

---
/bin/fortune:
He is more in debt but he weigh.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:22   ` Uriel
  2005-11-04  1:27     ` Uriel
@ 2005-11-04  1:56     ` Rian Hunter
  2005-11-04  2:08     ` Skip Tavakkolian
       [not found]     ` <000001c5e0e1$76791f80$14aaa8c0@utelsystems.local>
  3 siblings, 0 replies; 39+ messages in thread
From: Rian Hunter @ 2005-11-04  1:56 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Disclaimer:

Please don't take me the wrong way, I spent a large portion of today  
reading the Plan 9 papers and the descriptions behind sam and rc, as  
well as various man pages. I guess I didn't think to look in the  
window(1) man page for the answers to my question was because i  
thought this would be implemented in rc than in rio (basically  
because that's how its done in unix). I credit this blunder to still  
having a very unixish perception of Plan 9.

I knew about mouse-chording/send from reading doc on Acme, but I  
didn't realize it was also used in rio. Once I become more familiar  
with this interface I can see myself liking it a lot. As for now I'm  
still grumpy when I have to remove my hands from the home position on  
the keyboard, but i know that new ideas and innovation require change  
and challenge to old de factos and standards.

Thanks for your patience and immediate replies!

Rian Hunter

On Nov 3, 2005, at 8:22 PM, Uriel wrote:

> On Thu, Nov 03, 2005 at 08:14:29PM -0500, John Floren wrote:
>> As for command history, you are expected to
>> find the previous command in your rc window, edit it, copy it,  
>> paste it
>> to the prompt, and then run it.  This is obviously more efficient  
>> than
>> hitting the "up" arrow.
> No need to copy/paste(and if you do, do it mouse-chording), you can  
> use
> "Send" directly.
>
> Edit any line in your window, double click at the start or end of the
> line to select it, and then Middle-click->Send; is a very common and
> useful idiom(note that in the default profile your shell prompt is
> defined as a NOP function precisely for this).
>
> This are all FAQs, I think for the most part are well documented in  
> the
> papers, man pages and the Wiki; and of course lots of material and in
> the 9fans archives.
>
> The Plan 9 community can be friendly or harsh, but reading the docs is
> always well worth the time.
>
> uriel



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
@ 2005-11-04  1:29 Federico G. Benavento
  0 siblings, 0 replies; 39+ messages in thread
From: Federico G. Benavento @ 2005-11-04  1:29 UTC (permalink / raw)
  To: 9fans

>They complain that ^F doesn't work if rio's name space is different from the window in which ^F is typed.

you can use the "local" script in the tip o the day page, to change the
the plumbing namespace.

btw, I use ^F all the time, because I'm too lazy.


Federico G.Benavento

---
/bin/fortune:
He lost both Ali-pilaf and Vali-pilaf.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:22   ` Uriel
@ 2005-11-04  1:27     ` Uriel
  2005-11-04  2:02       ` Russ Cox
  2005-11-04  1:56     ` Rian Hunter
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 39+ messages in thread
From: Uriel @ 2005-11-04  1:27 UTC (permalink / raw)
  To: 9fans

One last note: one of the reasons why tab-completion is frowned upon is
because it's indication of too intricate paths, remember to keep your
file trees clean and simple and to take advantage of binds and union
mounts to keep everything at hand. If you do this you won't miss
tab-completion and you will have a much easier time finding what you are
looking for.

uriel

On Fri, Nov 04, 2005 at 01:22:35AM +0000, Uriel wrote:
> On Thu, Nov 03, 2005 at 08:14:29PM -0500, John Floren wrote:
> > As for command history, you are expected to
> > find the previous command in your rc window, edit it, copy it, paste it
> > to the prompt, and then run it.  This is obviously more efficient than
> > hitting the "up" arrow.
> No need to copy/paste(and if you do, do it mouse-chording), you can use
> "Send" directly.
> 
> Edit any line in your window, double click at the start or end of the
> line to select it, and then Middle-click->Send; is a very common and
> useful idiom(note that in the default profile your shell prompt is
> defined as a NOP function precisely for this).
> 
> This are all FAQs, I think for the most part are well documented in the
> papers, man pages and the Wiki; and of course lots of material and in
> the 9fans archives.
> 
> The Plan 9 community can be friendly or harsh, but reading the docs is
> always well worth the time.
> 
> uriel


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:14 ` John Floren
  2005-11-04  1:22   ` Russ Cox
  2005-11-04  1:22   ` Uriel
@ 2005-11-04  1:23   ` Paul Lalonde
  2005-11-04  9:02   ` Scott Schwartz
  2005-11-04 15:13   ` "Nils O. Selåsdal"
  4 siblings, 0 replies; 39+ messages in thread
From: Paul Lalonde @ 2005-11-04  1:23 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 986 bytes --]


On 3-Nov-05, at 5:14 PM, John Floren wrote:
> As for command history, you are expected to
> find the previous command in your rc window, edit it, copy it,  
> paste it
> to the prompt, and then run it.  This is obviously more efficient than
> hitting the "up" arrow.

Methinks you overstate the case...
The " and "" commands work beautifully - " searches the text in the  
window and spits out the lines of text that match a prompt followed  
by the given argument, you can then sweep the one you want and click- 
send it; "" runs the last match.  Things I prefer about this is that  
if you keep your path in the prompt, then you even get the directory  
context at hand for where the command was executed.  Handy.

That said, I don't do a lot of heavy work in a 9term - mostly I work  
in a win window in acme where the combination of 2-1 chording and  
button 3 searching is substantially more effective than 9term's  
somewhat awkward send mechanism.

Paul


[-- Attachment #2: Type: text/html, Size: 2260 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:14 ` John Floren
  2005-11-04  1:22   ` Russ Cox
@ 2005-11-04  1:22   ` Uriel
  2005-11-04  1:27     ` Uriel
                       ` (3 more replies)
  2005-11-04  1:23   ` Paul Lalonde
                     ` (2 subsequent siblings)
  4 siblings, 4 replies; 39+ messages in thread
From: Uriel @ 2005-11-04  1:22 UTC (permalink / raw)
  To: 9fans

On Thu, Nov 03, 2005 at 08:14:29PM -0500, John Floren wrote:
> As for command history, you are expected to
> find the previous command in your rc window, edit it, copy it, paste it
> to the prompt, and then run it.  This is obviously more efficient than
> hitting the "up" arrow.
No need to copy/paste(and if you do, do it mouse-chording), you can use
"Send" directly.

Edit any line in your window, double click at the start or end of the
line to select it, and then Middle-click->Send; is a very common and
useful idiom(note that in the default profile your shell prompt is
defined as a NOP function precisely for this).

This are all FAQs, I think for the most part are well documented in the
papers, man pages and the Wiki; and of course lots of material and in
the 9fans archives.

The Plan 9 community can be friendly or harsh, but reading the docs is
always well worth the time.

uriel


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  1:14 ` John Floren
@ 2005-11-04  1:22   ` Russ Cox
  2005-11-04  1:22   ` Uriel
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Russ Cox @ 2005-11-04  1:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> copy-pasting to be faster.  As for command history, you are expected to
> find the previous command in your rc window, edit it, copy it, paste it
> to the prompt, and then run it.  This is obviously more efficient than
> hitting the "up" arrow.

See /n/sources/contrib/rsc/scripts/" and /n/sources/contrib/rsc/scripts/""
for scripts that let you more easily find things in the rc window.

<rant>
As for ^F, I use it all the time and am very happy with it.  The #plan9
crowd is a bit too much into the religious fanaticism.  They complain
that ^F doesn't work if rio's name space is different from the window
in which ^F is typed.  That's true, but it's also true of the plumber
and yet the plumber is sacrosanct.  There's a lot in Plan 9 that works
only because of conventions.  It's very powerful when used properly.
For example, it's great that I can
   @{rfork n; import other-machine /proc; ps}
but not so great that I can
   @{rfork n; bind /env /proc; ps}
Is that an argument that ps or bind or /proc is a bad idea?  No.
It's an argument that you have to follow the conventions or
things get confused.
</rant>

Russ


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  0:59 Rian Hunter
  2005-11-04  1:06 ` Uriel
  2005-11-04  1:07 ` Russ Cox
@ 2005-11-04  1:14 ` John Floren
  2005-11-04  1:22   ` Russ Cox
                     ` (4 more replies)
  2 siblings, 5 replies; 39+ messages in thread
From: John Floren @ 2005-11-04  1:14 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Rian Hunter wrote:
> Hi,
> 
> I'm very very new to Plan 9 and I'm very conscious of the fact that 
> things are done differently if not better than in the unix family. In 
> bash and in some versions of csh and sh there is tab-completion and 
> command history (you get these effects by pressing tab or up, 
> respectively, on the keyboard). Does that exist in rc, or is it done  in
> different way in Plan 9?
> 
> Also on my keyboard my directional buttons no longer work, so in a 
> terminal window running in rio it's very frustrating when I get to  the
> bottom of the window and have to use the mouse to scroll down or  press
> enter twice. Is there a way so that the command line always  stays in
> sight in the terminal window? or, are there other key  sequences I can
> use to simulate up down left and right (similar to  hjkl in vi or ctrl+n
> or ctrl+p in emacs/bash).
> 
> Thanks!
> 
> Rian Hunter
> 
Ouch.  You seem to have unconsciously hit on some of the more hot-button
topics for Plan 9 users.  Tab completion is partly implemented; hit
"Ctrl-f".  However, as a quick foray onto #plan9 will tell you, nobody
seems to believe in tab completion, finding multiple "ls" commands and
copy-pasting to be faster.  As for command history, you are expected to
find the previous command in your rc window, edit it, copy it, paste it
to the prompt, and then run it.  This is obviously more efficient than
hitting the "up" arrow.
As for keeping the command line always in view, mid-click on the window
and select "scroll".  I really can't help you with regard to your
directional buttons.


John Floren
-- 
http://nuwen.net/~digi/cluster
Jealousy is all the fun you think they have.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  0:59 Rian Hunter
  2005-11-04  1:06 ` Uriel
@ 2005-11-04  1:07 ` Russ Cox
  2005-11-04  1:14 ` John Floren
  2 siblings, 0 replies; 39+ messages in thread
From: Russ Cox @ 2005-11-04  1:07 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I'm very very new to Plan 9 and I'm very conscious of the fact that
> things are done differently if not better than in the unix family. In
> bash and in some versions of csh and sh there is tab-completion and
> command history (you get these effects by pressing tab or up,
> respectively, on the keyboard). Does that exist in rc, or is it done
> in different way in Plan 9?

You can use ^F to get file name (not command) completion.
Command resending is done using the mouse (you can also
edit the command before resending it).

> Also on my keyboard my directional buttons no longer work, so in a
> terminal window running in rio it's very frustrating when I get to
> the bottom of the window and have to use the mouse to scroll down or
> press enter twice. Is there a way so that the command line always
> stays in sight in the terminal window?

Select "scroll" from the button-2 menu.

> or, are there other key
> sequences I can use to simulate up down left and right (similar to
> hjkl in vi or ctrl+n or ctrl+p in emacs/bash).

Page down or down arrow will scroll the window down too.

Your down arrow key probably doesn't work because you are using
an old drawterm.  Try running one of the binaries at
http://swtch.com/drawterm/ which are newer and have the
new key code for down arrow.

Russ


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [9fans] tab completion and command history in rc
  2005-11-04  0:59 Rian Hunter
@ 2005-11-04  1:06 ` Uriel
  2005-11-04  1:07 ` Russ Cox
  2005-11-04  1:14 ` John Floren
  2 siblings, 0 replies; 39+ messages in thread
From: Uriel @ 2005-11-04  1:06 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

See window(1)

On Thu, Nov 03, 2005 at 07:59:26PM -0500, Rian Hunter wrote:
> Hi,
> 
> I'm very very new to Plan 9 and I'm very conscious of the fact that  
> things are done differently if not better than in the unix family. In  
> bash and in some versions of csh and sh there is tab-completion and  
> command history (you get these effects by pressing tab or up,  
> respectively, on the keyboard). Does that exist in rc, or is it done  
> in different way in Plan 9?
> 
> Also on my keyboard my directional buttons no longer work, so in a  
> terminal window running in rio it's very frustrating when I get to  
> the bottom of the window and have to use the mouse to scroll down or  
> press enter twice. Is there a way so that the command line always  
> stays in sight in the terminal window? or, are there other key  
> sequences I can use to simulate up down left and right (similar to  
> hjkl in vi or ctrl+n or ctrl+p in emacs/bash).
> 
> Thanks!
> 
> Rian Hunter


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [9fans] tab completion and command history in rc
@ 2005-11-04  0:59 Rian Hunter
  2005-11-04  1:06 ` Uriel
                   ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Rian Hunter @ 2005-11-04  0:59 UTC (permalink / raw)
  To: 9fans

Hi,

I'm very very new to Plan 9 and I'm very conscious of the fact that  
things are done differently if not better than in the unix family. In  
bash and in some versions of csh and sh there is tab-completion and  
command history (you get these effects by pressing tab or up,  
respectively, on the keyboard). Does that exist in rc, or is it done  
in different way in Plan 9?

Also on my keyboard my directional buttons no longer work, so in a  
terminal window running in rio it's very frustrating when I get to  
the bottom of the window and have to use the mouse to scroll down or  
press enter twice. Is there a way so that the command line always  
stays in sight in the terminal window? or, are there other key  
sequences I can use to simulate up down left and right (similar to  
hjkl in vi or ctrl+n or ctrl+p in emacs/bash).

Thanks!

Rian Hunter


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2005-12-09  1:58 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-04  4:27 [9fans] tab completion and command history in rc YAMANASHI Takeshi
2005-11-04  5:28 ` Ronald G Minnich
2005-11-04  4:41   ` Matthew J. Sottile
2005-11-04  5:26   ` Jack Johnson
2005-11-04  8:50   ` lucio
2005-11-04 15:06   ` erik quanstrom
2005-11-04 15:24     ` Axel Belinfante
2005-11-04 15:29       ` erik quanstrom
2005-11-04 15:26     ` Charles Forsyth
2005-11-04 15:54       ` erik quanstrom
2005-11-05  9:20         ` Charles Forsyth
2005-11-04 16:27     ` Russ Cox
2005-12-09  1:58       ` erik quanstrom
2005-11-05  8:54     ` Scott Schwartz
2005-11-05 12:13       ` erik quanstrom
2005-11-05 16:01       ` Ronald G Minnich
     [not found] <000201c5e0e5$bbd617f0$14aaa8c0@utelsystems.local>
2005-11-04  6:46 ` Nils O. Selåsdal
  -- strict thread matches above, loose matches on Subject: below --
2005-11-04  4:01 YAMANASHI Takeshi
2005-11-04  3:42 YAMANASHI Takeshi
2005-11-04  3:45 ` Russ Cox
2005-11-04  2:30 YAMANASHI Takeshi
2005-11-04  3:08 ` Russ Cox
2005-11-04  2:01 Federico G. Benavento
2005-11-04  1:29 Federico G. Benavento
2005-11-04  0:59 Rian Hunter
2005-11-04  1:06 ` Uriel
2005-11-04  1:07 ` Russ Cox
2005-11-04  1:14 ` John Floren
2005-11-04  1:22   ` Russ Cox
2005-11-04  1:22   ` Uriel
2005-11-04  1:27     ` Uriel
2005-11-04  2:02       ` Russ Cox
2005-11-04  1:56     ` Rian Hunter
2005-11-04  2:08     ` Skip Tavakkolian
2005-11-04  9:20       ` William Staniewicz
     [not found]     ` <000001c5e0e1$76791f80$14aaa8c0@utelsystems.local>
2005-11-04  6:58       ` Nils O. Selåsdal
2005-11-04  1:23   ` Paul Lalonde
2005-11-04  9:02   ` Scott Schwartz
2005-11-04 15:13   ` "Nils O. Selåsdal"

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).