aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thyssen Tishman <johannes@thyssentishman.com>2024-03-27 17:33:49 +0100
committerRobin Jarry <robin@jarry.cc>2024-04-13 21:47:44 +0200
commit9849601906f3d53e38321e4b3a4461f60520bbca (patch)
treefebf9038745b312a2bb9b855be102960ab40fc0c
parent569a2720ca69ce4686f5d031c0937e2c365ca5fb (diff)
downloadaerc-9849601906f3d53e38321e4b3a4461f60520bbca.tar.gz
aerc-9849601906f3d53e38321e4b3a4461f60520bbca.zip
pipe: allow closing the terminal automatically
Add a new -s flag to :pipe. When specified, the terminal tab opened by the :pipe command will be automatically closed after the process is completed instead of prompting for a key press. While this doesn't technically silence the command (the output is not suppressed), the output is not shown to the user. Changelog-added: Silently close the terminal tab after piping a message to a command with `:pipe -s <cmd>`. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--commands/msg/pipe.go3
-rw-r--r--commands/util.go6
-rw-r--r--doc/aerc.1.scd2
3 files changed, 9 insertions, 2 deletions
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 7135df01..980ba38d 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -19,6 +19,7 @@ import (
type Pipe struct {
Background bool `opt:"-b"`
+ Silent bool `opt:"-s"`
Full bool `opt:"-m"`
Part bool `opt:"-p"`
Command string `opt:"..."`
@@ -60,7 +61,7 @@ func (p Pipe) Run(cb func()) error {
doTerm := func(reader io.Reader, name string) {
cmd := []string{"sh", "-c", p.Command}
- term, err := commands.QuickTerm(cmd, reader)
+ term, err := commands.QuickTerm(cmd, reader, p.Silent)
if err != nil {
app.PushError(err.Error())
return
diff --git a/commands/util.go b/commands/util.go
index 39c9dafc..b6a458fd 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -23,7 +23,7 @@ import (
)
// QuickTerm is an ephemeral terminal for running a single command and quitting.
-func QuickTerm(args []string, stdin io.Reader) (*app.Terminal, error) {
+func QuickTerm(args []string, stdin io.Reader, silent bool) (*app.Terminal, error) {
cmd := exec.Command(args[0], args[1:]...)
pipe, err := cmd.StdinPipe()
if err != nil {
@@ -40,6 +40,10 @@ func QuickTerm(args []string, stdin io.Reader) (*app.Terminal, error) {
app.PushError(err.Error())
// remove the tab on error, otherwise it gets stuck
app.RemoveTab(term, false)
+ return
+ }
+ if silent {
+ app.RemoveTab(term, true)
} else {
app.PushStatus("Process complete, press any key to close.",
10*time.Second)
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 66e86fdd..1351f5b6 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -403,6 +403,8 @@ message list, the message in the message viewer, etc).
*-b*: Run the command in the background instead of opening a terminal tab
+ *-s*: Silently close the terminal tab after the command is completed
+
*-m*: Pipe the full message
*-p*: Pipe just the selected message part, if applicable