Line editing and autocompletion with the ELKS shellELKS uses the ash or Almquist shell. This is the port for ELKS which was ported from the MINIX version in 1998. This had commented code to include the GNU Readline library or the editline library (by Simmule Turner and Rich Salz). These libraries provide a set of functions that allow users to edit command lines as they are typed in. They also include additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines. Both libraries were not used with ELKS, probably because of memory space requirements. I now added these functions using the small Linenoise library by Salvatore Sanfilippo from Sicily. It is available on GitHub at https://github.com/antirez/linenoise . This library was reduced in size and adapted to ELKS and its ash shell port. This library adds the following commands to allow for line editing and command history:
Autocompletion Linenoise features autocompletion (or TAB completion) which has been adapted for ELKS. a) if you enter one or more letters on the command line and press TAB, the shell will list the programs in the /bin directory that begin with these letters on the screen and put the first one of these on the command line. If only one program matches the letters entered, there will be no list shown and just this program will be put on the command line. You can select the program which is put on the command line by pressing enter or enter TAB again to get the next program in the list being displayed on the command line which you can then select with enter. b) if you enter "./" on the command line and press TAB, the shell will list the programs in the current directory and show the first of these on the command line. You can either select that with enter or press TAB to put the next program on the command line. c) if you enter e.g. ls, cat, vi etc. plus a blank and press TAB, the shell will list all the files in the current directory which are not executables on the screen and put the first one on the command line. You can select that with enter or press TAB to get the next one on the command line. This way you can select a file to use with ls, cat or vi using autocompletion. d) if you enter "cd " on the command line and press TAB, the shell will list all the directories in the current directory and put the first of them on the command line. If you press enter you can move into that directory, or select "cd .." from the list by pressing TAB to move up one directory. If you enter "cd /" and press TAB, the shell will display all the directories in the root directory. If you press TAB again you can select one of these. 18th of April 2020 Georg Potthast
|