From a0eacf4607f0262f6c3bb6ddf84113253b76d477 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= <p@janouch.name>
Date: Wed, 21 Oct 2020 08:18:39 +0200
Subject: Add an installation script

Copying snippets from the README was uncomfortable and laborious,
and wasted a lot of space in the document, especially after
the recent additions.

Closes #3
---
 README.adoc | 120 +++++-------------------------------------------------------
 1 file changed, 10 insertions(+), 110 deletions(-)

(limited to 'README.adoc')

diff --git a/README.adoc b/README.adoc
index bedacd6..9c162a6 100644
--- a/README.adoc
+++ b/README.adoc
@@ -47,117 +47,17 @@ into the PATH of any machine you want to have 'sdn' on.
 
 Integration
 -----------
+The package contains an installation script called 'sdn-install' which will bind
+'sdn' to M-o in your shell's initialisation file.  The supported shells are:
 
-zsh
-~~~
-To start using this navigator, put the following in your '.zshrc':
-
-----
-sdn-navigate () {
-  # ... possibly zle-line-finish
-  while eval "`sdn "$BUFFER" "$CURSOR"`"; do
-    [ -z "$cd" ] || cd "$cd"
-    [ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
-    [ -z "$helper" ] && break
-
-    # Workaround for "zsh: suspended (tty output)" when invoking
-    # helpers after the terminal has been resized while running sdn
-    command true
-
-    /bin/sh -c "$helper" </dev/tty || break
-  done
-  # ... possibly zle-line-init
-  zle reset-prompt
-}
-zle -N sdn-navigate
-bindkey '\eo' sdn-navigate
-----
-
-bash
-~~~~
-Here we can't make the shell update the prompt on directory changes since
-there's no way to invoke `prompt_again()` from a `bind -x` handler but we can
-work around it by submitting a blank line:
-
-----
-sdn-cursor () {
-  if [[ $BASH_VERSINFO -lt 5 ]]
-  then echo -n "$SDN_L" | wc -m
-  else echo "$SDN_P"
-  fi
-}
-sdn-navigate () {
-  SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT
-  READLINE_LINE=
-
-  while eval "`sdn "$SDN_L" "$(sdn-cursor)"`"; do
-    [[ -z $cd ]] || cd "$cd"
-    [[ -z $insert ]] || {
-      SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}"
-      ((SDN_P=SDN_P+${#insert}+1))
-    }
-    [[ -z $helper ]] && break
-    /bin/sh -c "$helper" || break
-  done
-}
-sdn-restore () {
-  READLINE_LINE=$SDN_L READLINE_POINT=$SDN_P
-  unset SDN_L SDN_P
-}
-
-bind -x '"\200": sdn-navigate'
-bind -x '"\201": sdn-restore'
-bind '"\eo":"\200\C-m\201"'
-----
-
-fish
-~~~~
-To start using this navigator, put the following in your 'config.fish':
-
-----
-function sdn-navigate
-  set --local IFS
-  set --local buffer (commandline)
-  set --local cursor (commandline --cursor)
-  while eval (sdn $buffer $cursor | string replace -ar '^(.*?)=' 'set --$1 ')
-    test -z "$cd" || cd "$cd"
-    test -z "$insert" || commandline --insert "$insert "
-    test -z "$helper" && break
-    /bin/sh -c "$helper" || break
-  end
-  commandline --function repaint
-end
-bind \eo sdn-navigate
-----
-
-elvish
-~~~~~~
-To start using this navigator, put the following in your 'rc.elv':
-
-----
-use str
-edit:insert:binding[Alt-o] = {
-  local:reesc = [posix]{ str:replace "'\\''"  "''" $posix }
-  local:posix = [cmd]{ /bin/sh -c $cmd </dev/tty >/dev/tty 2>&1 }
-
-  # XXX: the -dot is not a stable API, and may hence break soon
-  local:buffer = $edit:current-command
-  local:cursor = (str:to-codepoints $buffer[0..$edit:-dot] | count)
-  local:ns = (ns [&])
-  while ?(eval ($reesc (sdn $buffer $cursor |
-    sed 's/^local //' | slurp)) &ns=$ns) {
-    if (not-eq $ns[cd] "") { cd $ns[cd] }
-    if (not-eq $ns[insert] "") { edit:insert-at-dot $ns[insert]" " }
-    if (or (eq $ns[helper] "") (not ?($posix $ns[helper]))) { break }
-  }
-  edit:redraw &full=$true
-}
-----
-
-This shell is absolutely perverse.  And so is integrating 'sdn' into it because
-it already includes a custom file manager, bound to Ctrl-N (though I find
-the ranger-like interface confusing and resource-demanding).  Version 0.14.1 or
-newer is required.
+ - *zsh*: works well
+ - *bash*: minor issue: exiting the navigator confirms an empty prompt
+ - *fish*: works well
+ - *elvish*: version 0.14.1 and above, an unstable API is used, works well
+
+elvish is absolutely perverse.  And so is integrating 'sdn' into it because it
+already includes a custom file manager, bound to Ctrl-N (though I find the
+ranger-like interface confusing and resource-demanding).
 
 Configuration
 -------------
-- 
cgit v1.2.3

