1

my router runs asuswrt merlin. the /bin/sh is packaged in BusyBox v1.25.1 (2017-12-02 00:49:46 EST) multi-call binary.

my question is how do I move my cursor one word left and right?

with bash, i can do option+left, option+right, which is mapped in terminal to \033b and \033f respectively.

on my router's shell, it just prints a b and an f. so how do i remap shortcuts in shell or what out of the (busy)box shortcut is there?

Note 1: i found that busybox supposedly packages ash shell, so my question may be how to move cursor one word with ash shell.

Note 2: i tried enabling and disabling the following option to use meta+b and meta+f, no luck

using option as meta key

Note 3: added apple and ash tags

1
  • So when you say option+left you are on a Apple computer? If so, you may want to add Apple tag. Commented Jan 25, 2018 at 15:46

2 Answers 2

1

Meta-F and Meta-B will move the cursor forward and back word by word, respectively.

If you're on a terminal or connection chain that does not properly pass the Meta key along for the ride, as appears to be your case, Esc is a signal that the next character sent it meant to be a keystroke altered by Meta. So: Press and release Esc, followed by F or B to go forward or back in word-by-word your remote terminal, respectively.

That said, when a command line I'm working on is complex enough to set right that I need anything more complex than Ctrl-A or Ctrl-E, I will usually just open it up in my configured EDITOR with Ctrl-X, Ctrl-E.

7
  • when i press meta+b and meta+f i get ƒ and , so that doesn't seem to be the right shortcut. Commented Jan 25, 2018 at 15:27
  • Meta and Option are two wholly different keys. Did you try Esc,F and Esc,B?
    – DopeGhoti
    Commented Jan 25, 2018 at 15:32
  • i'm on macOS so terminal has this option to send meta using the option key, which i've tried both Commented Jan 25, 2018 at 15:33
  • If you're getting ƒ and ∫, that means the Mac is handling its keyboard shortcuts for the Option key before your keystroke is making it to the Terminal program you are using. Try the Escape-based alternative which does not require the use of Meta.
    – DopeGhoti
    Commented Jan 25, 2018 at 15:36
  • 2
    The questioner actually did say in the question that this is the Almquist shell, as included in BusyBox. That does not use Readline. But it does have word motions in its own line editing library.
    – JdeBP
    Commented Jan 25, 2018 at 17:10
0

As JdeBP said, BusyBox does not use readline. Its key mappings are hardcoded in its read_key.c file and interpreted by lineedit.c, which means that ~/.inputrc, /etc/inputrc, termcap and terminfo have no effect. v1.25 hard-codes word-left as ESC[1;5D or ESC[1;3D, and word-right as ESC[1;5C or ESC[1;3C, corresponding to obscure xterm variants for mapping Ctrl-arrow/Alt-arrow. v1.26 added ESC-b/ESC-f for backward-word/forward-word, which is usually mapped to Alt-b/Alt-f.

1
  • 1
    Please use syntax to improve readability
    – mattia.b89
    Commented Jul 12, 2020 at 9:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .