summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.go17
-rw-r--r--doc/senpai.5.scd16
2 files changed, 16 insertions, 17 deletions
diff --git a/app.go b/app.go
index a336588..61171a0 100644
--- a/app.go
+++ b/app.go
@@ -4,6 +4,7 @@ import (
"crypto/tls"
"fmt"
"net"
+ "os"
"os/exec"
"strings"
"time"
@@ -555,14 +556,14 @@ func (app *App) notifyHighlight(buffer, nick, content string) {
if buffer == app.win.CurrentBuffer() {
here = "1"
}
- r := strings.NewReplacer(
- "%%", "%",
- "%b", buffer,
- "%h", here,
- "%n", nick,
- "%m", cleanMessage(content))
- command := r.Replace(app.cfg.OnHighlight)
- output, err := exec.Command(sh, "-c", command).CombinedOutput()
+ cmd := exec.Command(sh, "-c", app.cfg.OnHighlight)
+ cmd.Env = append(os.Environ(),
+ fmt.Sprintf("BUFFER=%s", buffer),
+ fmt.Sprintf("HERE=%s", here),
+ fmt.Sprintf("SENDER=%s", nick),
+ fmt.Sprintf("MESSAGE=%s", cleanMessage(content)),
+ )
+ output, err := cmd.CombinedOutput()
if err != nil {
body := fmt.Sprintf("Failed to invoke on-highlight command: %v. Output: %q", err, string(output))
app.win.AddLine(Home, false, ui.Line{
diff --git a/doc/senpai.5.scd b/doc/senpai.5.scd
index 1218f73..5aab8e3 100644
--- a/doc/senpai.5.scd
+++ b/doc/senpai.5.scd
@@ -39,19 +39,17 @@ Some settings are required, the others are optional.
*on-highlight*
A command to be executed via _sh_ when you are highlighted. The following
- format specifiers are expanded with respect to the highlight:
+ environment variables are set with repect to the highlight:
-[[ *Format specifier*
+[[ *Environment variable*
:< *Description*
-| %%
-: literal %
-| %b
+| BUFFER
: buffer where the message appeared
-| %h
-: equals 1 if _%b_ is the current buffer, 0 otherwise
-| %m
+| HERE
+: equals 1 if _BUFFER_ is the current buffer, 0 otherwise
+| MESSAGE
: content of the message
-| %n
+| SENDER
: nickname of the sender
*nick-column-width*