zsh-users
 help / color / mirror / code / Atom feed
* history sharing between ttys
@ 1997-02-13 23:53 Herb Maeder
  1997-02-14  1:26 ` Steve Reid
  0 siblings, 1 reply; 3+ messages in thread
From: Herb Maeder @ 1997-02-13 23:53 UTC (permalink / raw)
  To: zsh-users

While we are on the subject of history...  I seem to remember from using a
version of ksh way back when, that it was possible to set it up so that you
can share history between multiple ttys.  So if I typed a command in one
window, I could retrieve and execute it from another window.  

I imagine there is some overhead for doing this, since I believe that it was
just done by maintaining one common history file that was updated after each
command.  But it was really quite useful since it reduces the need to cut
and paste and is especially useful for retrieving those long, interesting
commands when you log on from a different machine. 

Is it currently possible to do something like this in zsh?  If not, are
there plans to support it in the future?

Herb.


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

* Re: history sharing between ttys
  1997-02-13 23:53 history sharing between ttys Herb Maeder
@ 1997-02-14  1:26 ` Steve Reid
  1997-02-14  8:07   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Reid @ 1997-02-14  1:26 UTC (permalink / raw)
  To: Herb Maeder; +Cc: zsh-users

> While we are on the subject of history...  I seem to remember from using a
> version of ksh way back when, that it was possible to set it up so that you
> can share history between multiple ttys.  So if I typed a command in one
> window, I could retrieve and execute it from another window.  

Something like this? Last time I tried it (zsh 3.0.2) it didn't work
correctly... I was told that it was because of a bug in the new history
code.

precmd() {
	fc -AI ~$USER/.history;	# Append latest commands
	fc -R ~$USER/.history;	# Read changes from all zsh's
}                                         

I remember using the bash equivalent before I switched to zsh. The only
problem was that it doesn't update the history until after the command
exits, so commands aren't always saved in the correct order.

Ideally, it should be possible to append the command to the history
file immediately after the command is entered. Other running zsh's
should detect the change and read it, so the user doesn't have to hit
enter every time they switch ttys.

Wishlist:
 setopt synchronize_histories


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

* Re: history sharing between ttys
  1997-02-14  1:26 ` Steve Reid
@ 1997-02-14  8:07   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1997-02-14  8:07 UTC (permalink / raw)
  To: Steve Reid, zsh-users

On Feb 13,  5:26pm, Steve Reid wrote:
} Subject: Re: history sharing between ttys
}
} > [...] set it up so that you
} > can share history between multiple ttys.  So if I typed a command in one
} > window, I could retrieve and execute it from another window.  
} 
} Something like this? Last time I tried it (zsh 3.0.2) it didn't work
} correctly... I was told that it was because of a bug in the new history
} code.
} 
} precmd() {
} 	fc -AI ~$USER/.history;	# Append latest commands
} 	fc -R ~$USER/.history;	# Read changes from all zsh's
} }                                         

This appears to work fine in zsh 3.0.3-test4 (although I have applied a
couple of other patches, I don't think any of them would affect this).

However, the behavior is a little strange, because you immediately read
back not only everything the other shell wrote, but also everything you
just wrote, which causes the event numbers to jump by large increments at
every command.  The following seems to work a bit better; the event number
jumps only when some other zsh has actually written the file:

    precmd() {
	if [[ ~/.history -nt ~/.history-$HOST-$$ ]]
	then
	    fc -AI ~/.history
	    fc -R ~/.history
	else
	    fc -AI ~/.history
	fi
	<~/.history >| ~/.history-$HOST-$$
    }

} Ideally, it should be possible to append the command to the history
} file immediately after the command is entered.

Write a zsh 3.1 module that fronts for the `accept-line' ZLE action ...

} Other running zsh's
} should detect the change and read it, so the user doesn't have to hit
} enter every time they switch ttys.

That's almost doable:	TMOUT=10 ; trap precmd ALRM

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

end of thread, other threads:[~1997-02-14  8:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-13 23:53 history sharing between ttys Herb Maeder
1997-02-14  1:26 ` Steve Reid
1997-02-14  8:07   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).