syntax.xle – kandiszucker

Posted on April 12, 2022 by na

english title: how to make xle prompt react as expected

In the previous articles we discussed how to define custom abbreviations in order to speed up the feedback loop. One of the motivations and reasons for that comes from the fact that you cannot use your arrow keys or standard shell-prompt shortcuts like ctrl+a or ctrl+e to jump to the beginning or ending of the line respectively. Want to change a typo a bunch of characters before the current cursor position? Then backspace + rewriting s seems to be your only choice.

> xle

XLE loaded from xle.
...
Type 'help' for more information.

% aasd^A^E

% hellp^[[D^[[D

Plus, you need to remove the verbose ^[[D code sequences representing your arrow keys. How annyoing. (And most certainly you will have to remove sequences like ^[[D^[[D^[[D^[[C^[[C^[[A because we’re so quick.) And that’s a big frustration, as you might already be in some kind of debugging mode, trying to run a modified version of your previous command to understand what the heck was going on.

Hopefully you already know how copy/paste works in your terminal emulator, as ctrl+c is already going to exit your xle-shell (which might be an appropriate choice in this case). (Try shift+ctrl+c/v, if your finger coordination allows for that.)

Luckily there exists a simple solution to make xle behave as expected by wrapping it with a proper readline implementation.

On github you can find hanslub42/rlwrap providing such functionality.

Install it and simply enjoy using common shortcuts, keybindings and most importantly: your arrow keys!

> rlwrap xle

XLE loaded from xle.
...
Type 'help' for more information.

% help

% I quickly corrected all of my typos and modified the beginning of this long line with ease.

Oh, and did I mention: Arrow-up let’s you scroll through your command history.

And as there is no reason to ever call xle without that, let’s put an alias into our shell-runcommands file ~/.bashrc:

# .bashrc

alias xle="rlwrap xle"

Safe the file. Open new shell or run source ~/.bashrc to run the RunCommands commands in the current shell instance.