Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

shell script that replaces the command line



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% 


Messages sorted by: Reverse Date, Date, Thread, Author