Closed subsetpark closed 8 years ago
Es has no special keybindings, it just lets readline()
do its job and the only thing it changes is history handling and quoting characters. The documentation listing default readline keybindings and how to change them is in info rluserman
.
As long as you have es compiled with readline support, C-a
should by default behave just as you expect, and it does for me. It could be changed in inputrc, but you would probably know about it, so I'm guessing you might have compiled it without readline. Does any kind of line editing work for you in it?
Yes; it's a bit strange, actually. It's something to do with my esrc
(Basically just this one) but I can't tell what.
If I rename that to .esrc_
and start a new session, readline commands work fine. Then, if I . ~/.esrc_
, readline commands work in a trivial case:
foo|
<C-a>
|foo
ls a|
<C-a>
|ls a
But in a slightly more complex case, they don't:
ls a b|
<C-a>
ls a b |
It seems that the behavior is correct; in fact, the edit point is now at the beginning of the same line—but the visual cursor jumps a bunch of spaces to the right and any new text appears over there as well.
I'm running the version of es-shell
that you get from homebrew on OS X; I have confirmed this behavior on a few different terminal applications.
So it seems like it must be an issue with the prompt function defined in that esrc
:
# colourful prompt
let (cd = $fn-cd; c = \1\033; z=\2) fn cd {
$cd $*;
let (w = `pwd) {
if {~ $^w $home^*} {
w = '~'^<={~~ $^w $home^*}
}
prompt = $c[4\;35m$z`{hostname}^$c[0m$z:$c[1\;34m$z$^w$c[0m$z^'; '
}
}
Hmm, I don't have time to look into this right now, but it sounds like something is going wrong with \1 and \2, which should tell readline that there are non-printing characters (i.e. not to be counted when it moves back to the start of the line).
For amusing reference, my current prompt function has got completely out of control:
fn %prompt {
let (old-bqstatus = $bqstatus) {
if {~ $TERM xterm* rxvt*} {
echo -n \033]0\;$promptwd\007
}
# TODO God this is ugly. Separate prompt calculation...
let (e = \033; a=\1; z=\2; branch=`{git rev-parse --abbrev-ref HEAD >[2] /dev/null}; aws-role=$AWS_ROLE_NAME) {
if {!~ $branch ()} {
branch = ' ['^$branch^']'
}
if {!~ $aws-role ()} {
aws-role = ' | '^$aws-role' ('`{expr '(' `{date +%s} - $AWS_SAML_TIME ')' / 60}'mins)'
}
prompt = $a$e[4\;35m$host$e^'[0m:'^$e^'[1;34m'^$promptwd$e^'[0m'^$^branch$^aws-role$z^\n^'; '
}
bqstatus = $old-bqstatus
}
}
(let that be a lesson to never run things in your prompt function... notice bqstatus hack on the end :( )
Ah, another thought: you may just have resized your terminal when es wasn't active. e.g. if you're in an editor, and resize your terminal, readline doesn't automatically pick up that there's a new terminal size, so readline gets confused about line wrapping. I should raise an issue for this, though I don't know if it's possible to fix without messing with libreadline.
Actually @wryun, I experience the same behavior when using the esrc file you currently have in https://github.com/wryun/config. And I can produce it when opening a new session without resizing or tabbing out.
Ah, I think if you're on the release version it's because you're missing this commit:
https://github.com/wryun/es-shell/commit/24c5af02c34e7dec7872a577931d350aa5529ea2
(that's an internal change to es to stop it conflicting with readline, that's unfortunately not in the currently released version. I really should release another version)
Yes, please do that!! 😄
Done! Not sure when brew will get it, but it's a simple ./configure && make install if you want in /usr/local
Thanks @wryun !
I am used to CTRL-A in a shell moving to the beginning of the line. In
es
it doesn't; Indeed I'm not sure what it does.1) What is it doing? 2) How do I move to the beginning of the line? 3) Is there documentation of all keybindings in es?