zsh-workers
 help / color / mirror / code / Atom feed
* shell script that replaces the command line
@ 2014-06-12 23:07 Dave Yost
  2014-06-13  6:40 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Yost @ 2014-06-12 23:07 UTC (permalink / raw)
  To: zsh-workers

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

Hi.

Can a shell function replace the command line contents? I know a widget can do it, but I can’t see a way for a shell function to do that.

The use case is my “d” command I’ve been using for years. It is a fancy shell function that runs a command in the background with all output to a file. Optionally, it can rerun the previously-backgrounded command again or echo it.

When I want to rerun a command, I want my d shell function to put the previously-backgrounded command in the BUFFER so I can edit it before rerunning it.

Thanks

Dave

0 Thu 13:33:58 DaveBook yost /Users/yost
201 Z% d c echo ha
[5] 4595
0 Thu 13:34:11 DaveBook yost /Users/yost
202 Z% 
[5]  + 4595 done       yostD_runToOutfileWithEpilogue
0 Thu 13:34:11 DaveBook yost /Users/yost
202 Z% cat out
=d= tbegin 2014-06-12T13:34:11 PDT Thu
=d= see    http://yost.com/computers/d/
=d= host   ip2
=d= uname  Darwin ip2 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
=d= path   /Users/yost/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin::
=d= wd     /Users/yost
=d= cmd    echo ha
=d==begin / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
ha
  0.01s user 0.02s system 143% cpu 0.024 total
=d==end   \ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /
=d= status 0
=d= tend   2014-06-12T13:34:11 PDT Thu
========== =====================================================================
0 Thu 13:34:14 DaveBook yost /Users/yost
203 Z% d sp
echo ha
0 Thu 13:34:25 DaveBook yost /Users/yost
204 Z% d s
[ echo ha ]
[5] 4647
0 Thu 13:34:28 DaveBook yost /Users/yost
205 Z% 
[5]  + 4647 done       yostD_runToOutfileWithEpilogue
0 Thu 13:34:29 DaveBook yost /Users/yost
205 Z% 

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

end of thread, other threads:[~2014-06-17  4:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 23:07 shell script that replaces the command line Dave Yost
2014-06-13  6:40 ` Bart Schaefer
2014-06-13  7:22   ` Dave Yost
2014-06-13 21:34   ` Dave Yost
2014-06-13 22:02     ` Bart Schaefer
2014-06-17  4:31       ` Dave Yost
2014-06-14  9:45     ` Mikael Magnusson

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