The manner in which the line editor's history navigation works grates with some users, who would prefer that pressing cursor up/down would more directly navigate thru history...
It would be nice to support history navigation in a manner that is more familiar to experienced terminal users.
Simplistically this means cursor up/down should step directly thru history... but in reality the behaviour needs to be a bit more sophisticated to ensure sensible operation.
The behaviour observed in my Mac's terminal is as follows:
- on an empty line, cursor up/down will navigate thru history
- when the line editor already has some contents, history is navigated against entries that have a string match up to the cursor position
- if there are no matches found the line will not change, although if "up" is pressed the cursor will be moved to the end of the line
- if a line was edited then one can step back to the edited version via up/down (as appropriate), which will also restore the previous cursor position
- on replacement lines, the cursor position will be at the end of the line
- NB matching continues to be based on string up to original cursor position until the cursor is moved either via typing or left/right
The final bullet point here (stepping back to an edited version of a line) could be viewed as a "stretch goal"...
It should be noted that this behaviour is not compatible with the existing line editor cursor up/down key handling, which will move the cursor within a multi-line input... This enhanced behaviour should therefore probably be optional, and not the default. This behaviour could be enabled via setting suitable system variable(s). We could consider supporting three modes of operation as follows:
- existing line editor behaviour
- cursor up/down navigates history (up to cursor position), as per above
- cursor up/down supports moving cursor within a multi-line input, but on first/last line does not do beginning/end line and instead does direct history navigation
The manner in which the line editor's history navigation works grates with some users, who would prefer that pressing cursor up/down would more directly navigate thru history...
It would be nice to support history navigation in a manner that is more familiar to experienced terminal users.
Simplistically this means cursor up/down should step directly thru history... but in reality the behaviour needs to be a bit more sophisticated to ensure sensible operation.
The behaviour observed in my Mac's terminal is as follows:
The final bullet point here (stepping back to an edited version of a line) could be viewed as a "stretch goal"...
It should be noted that this behaviour is not compatible with the existing line editor cursor up/down key handling, which will move the cursor within a multi-line input... This enhanced behaviour should therefore probably be optional, and not the default. This behaviour could be enabled via setting suitable system variable(s). We could consider supporting three modes of operation as follows: