Line editing in dash
In bash or mksh it is possible to move around the typed line word by word, using shortcuts such as ESCB.
That doesn't work in ksh or dash. As far as I understand from googling, this has something to do with readline support, however nowhere I've seen it mention how to enable support for dash.
That's the core of my question: How to enable line navigation for dash
If you definitely want dash
plus command-line editing and history, you can use rlwrap
:
rlwrap dash
Suggestion:
rlwrap -cmD2 dash
To use rlwrap
, you'll have to:
sudo apt-get install rlwrap
The short answer is:
You don't.
dash
is a direct descendent of the Almquist Shell (ash
). ash
never featured line editing support, and neither does dash
. Busybox ash
does, so if you must an ash
variant for some reason and have line editing, etc., use Busybox ash
. Nobody's going to bother with adding readline support, since dash
's primary use is for running shell scripts.
Unless, of course, you're willing to code support for readline in dash
, and maintain such a patch yourself...
The long answer is:
Compile with libedit
If you look at dash
's manpage:
-V vi Enable the built-in vi(1) command line editor
(disables -E if it has been set).
-E emacs Enable the built-in emacs(1) command line editor
(disables -V if it has been set).
These only work if dash
was compiled with --with-libedit
. It isn't, neither in Ubuntu, nor, apparently, in Debian.
You can build it thus:
git clone https://git.kernel.org/pub/scm/utils/dash/dash.git
cd dash
./autogen.sh
./configure --with-libedit
make
Then run:
src/dash -E
You should be able to use the arrow keys to edit the current command.