Figure out bash
This commit is contained in:
parent
571447298a
commit
4fa98abec3
35
README.adoc
35
README.adoc
@ -41,20 +41,43 @@ zsh
|
|||||||
---
|
---
|
||||||
To start using this navigator, put the following in your .zshrc:
|
To start using this navigator, put the following in your .zshrc:
|
||||||
....
|
....
|
||||||
navigate () {
|
sdn-navigate () {
|
||||||
# ... possibly zle-line-init
|
# ... possibly zle-line-init
|
||||||
eval `navigator`
|
eval `sdn`
|
||||||
[ -z "$cd" ] || cd "$cd"
|
[ -z "$cd" ] || cd "$cd"
|
||||||
[ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
|
[ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
# ... possibly zle-line-finish
|
# ... possibly zle-line-finish
|
||||||
}
|
}
|
||||||
zle -N navigate
|
zle -N sdn-navigate
|
||||||
bindkey '\eo' navigate
|
bindkey '\eo' sdn-navigate
|
||||||
....
|
....
|
||||||
|
|
||||||
As far as I'm aware, bash cannot be used for this, as there is no command to
|
bash
|
||||||
reset the prompt from within a `bind -x` handler.
|
----
|
||||||
|
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
|
Colors
|
||||||
------
|
------
|
||||||
|
Loading…
Reference in New Issue
Block a user