From 9a12fd80213c985fc91ee75854918523106377f3 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Tue, 29 Sep 2020 00:55:01 +0200
Subject: Add ability to run helpers externally
So far experimental and essentially undocumented.
---
README.adoc | 25 +++++++++++++++----------
sdn.cpp | 24 +++++++++++++++++++++---
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/README.adoc b/README.adoc
index e49cbce..5ca0e5f 100644
--- a/README.adoc
+++ b/README.adoc
@@ -52,9 +52,11 @@ To start using this navigator, put the following in your .zshrc:
....
sdn-navigate () {
# ... possibly zle-line-init
- eval "`sdn`"
- [ -z "$cd" ] || cd "$cd"
- [ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
+ while eval "`sdn`"; do
+ [ -z "$cd" ] || cd "$cd"
+ [ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
+ [ -z "$helper" ] && break
+ eval "exec list, const string &filename) {
- endwin ();
+ if (g.ext_helpers) {
+ // XXX: this doesn't try them all out, though it shouldn't make any
+ // noticeable difference
+ const char *found = nullptr;
+ for (auto program : list)
+ if ((found = program))
+ break;
+ g.ext_helper = "/bin/sh -c " +
+ shell_escape (string (found) + " " + shell_escape (filename));
+ g.quitting = true;
+ return;
+ }
+ endwin ();
switch (pid_t child = fork ()) {
int status;
case -1:
@@ -853,8 +867,8 @@ fun run_program (initializer_list