diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-06-30 22:51:52 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-06-30 22:51:52 +0200 |
commit | 4fa98abec391fd03e11ec404d819b2bd5584e854 (patch) | |
tree | a85aa074dac8f7abfbe59a549ef9e2d0a320f56f | |
parent | 571447298ae0b02527c94e7a26cd6451e520dd96 (diff) | |
download | sdn-4fa98abec391fd03e11ec404d819b2bd5584e854.tar.gz sdn-4fa98abec391fd03e11ec404d819b2bd5584e854.tar.xz sdn-4fa98abec391fd03e11ec404d819b2bd5584e854.zip |
Figure out bash
-rw-r--r-- | README.adoc | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/README.adoc b/README.adoc index b1c78f0..1b9cdd2 100644 --- a/README.adoc +++ b/README.adoc @@ -41,20 +41,43 @@ zsh --- To start using this navigator, put the following in your .zshrc: .... -navigate () { +sdn-navigate () { # ... possibly zle-line-init - eval `navigator` + eval `sdn` [ -z "$cd" ] || cd "$cd" [ -z "$insert" ] || LBUFFER="$LBUFFER$insert " zle reset-prompt # ... possibly zle-line-finish } -zle -N navigate -bindkey '\eo' navigate +zle -N sdn-navigate +bindkey '\eo' sdn-navigate .... -As far as I'm aware, bash cannot be used for this, as there is no command to -reset the prompt from within a `bind -x` handler. +bash +---- +Here we can't reset the prompt from within a `bind -x` handler but there is +an acceptable workaround: +.... +sdn-navigate () { + SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT + READLINE_LINE= + + eval `sdn` + [[ -z "$cd" ]] || cd "$cd" + [[ -z "$insert" ]] || { + SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}" + ((SDN_P=SDN_P+${#insert}+1)) + } +} +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"' +.... Colors ------ |