Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
shell script that replaces the command line
- X-seq: zsh-workers 32769
- From: Dave Yost <Dave@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: shell script that replaces the command line
- Date: Thu, 12 Jun 2014 16:07:38 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:content-type:subject:message-id:date:to:mime-version; bh=WMUuu5VpznnH4VHg4sZohRgv9chUrk9OP/S22PZJdoI=; b=m6GkIQ4ObF6VZDTqLisptH2XUK7Age7cO1o/5gZ/YXTJCeCERSK/ASqn9j8w3+bcSQ HPgNPylYztVVoknxEbAz1fBa0QrdLyux5p0CzsAMJxfAqytRFAjpouTPlELc00qi5lxg nmOHC/Nx+87hGseW/wdLRaKSNey01u9W6a4lnXtryV7dqWuuDFwQQvtjVP9OGbqFGtDX kSATqs3HQarkdero0lr70gPERl9ZrMlb84tFzurN8GczHIJtnEeqkwCoQVlvhFCicyux X1A/NoUqxkd5PxMOQOkvi1Q6+h/pMrGVI59NDpG0LhsKTtdQz4FpFVkDl3BL6ty0sywU PC2Q==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Sender: Dave Yost <daveyostcom@xxxxxxxxx>
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