Re: Strange ksh history behaviour
On Mon, Jan 07, 2013 at 02:09:01PM +0100, Lars von den Driesch wrote: However, I like vim and as soon as I set the EDITOR env variable to it the arrow up/down functionality is gone. In fact even if EDITOR is set with export EDITOR= the functionality is gone. Commands typed in still appear in the history using fc -l. I just cannot use the arrow-keys. What am I missing here? Can someone confirm this? It's a silly ksh misfeature. ksh switches to vi editing mode as soon as vi is set as an editor. I also prefer emacs editing mode in the shell but use vim, so I put the following line into ~/.kshrc (or ~/.profile if you prefer) to force emacs editing mode in ksh regardless of what EDITOR is set to: set -o emacs
Re: Strange ksh history behaviour
On Mon, Jan 07, 2013 at 02:09:01PM +0100, Lars von den Driesch wrote: Hello, I just discovered a strange behaviour with ksh-history that I cannot explain. So I hope you can probably help. I read some man pages and used google but didn't find anything useful. If this is is just a RTFM please hit me with it :-) ready ? :-) [...] However, I like vim and as soon as I set the EDITOR env variable to it the arrow up/down functionality is gone. In fact even if EDITOR is set with export EDITOR= the functionality is gone. Commands typed in still appear in the history using fc -l. I just cannot use the arrow-keys. It is the documented behaviour in ksh(1) :-) You could see the EDITOR variable comment in ksh(1): EDITOR If the VISUAL parameter is not set, this parameter controls the command-line editing mode for interactive shells. And as arrow-keys are not used by the 'vi'-like command-line editing... What am I missing here? Can someone confirm this? You need to set your command-line editing mode to emacs. In order to keep EDITOR to vi, you should set VISUAL to emacs in your .profile: VISUAL=emacs EDITOR=vi export VISUAL EDITOR -- Sebastien Marie
Re: Strange ksh history behaviour
Stefan Sperling writes: On Mon, Jan 07, 2013 at 02:09:01PM +0100, Lars von den Driesch wrote: However, I like vim and as soon as I set the EDITOR env variable to it the arrow up/down functionality is gone. In fact even if EDITOR is set with export EDITOR= the functionality is gone. Commands typed in still appear in the history using fc -l. I just cannot use the arrow-keys. What am I missing here? Can someone confirm this? It's a silly ksh misfeature. ksh switches to vi editing mode as soon as vi is set as an editor. Well, that's one part of the problem. The other issue is that arrow keys don't work in vi mode even though they probably should.
Re: Strange ksh history behaviour
On 07.01.2013 14:54, Sébastien Marie wrote: In order to keep EDITOR to vi, you should set VISUAL to emacs in your .profile: VISUAL=emacs EDITOR=vi export VISUAL EDITOR Thanks a lot. You just solved one of those small problems I've had for years on all my OpenBSD systems. It was a pain in the ass to me at rare intervals. Therefore I was too lazy to read the man page. But now I'm very happy about knowing this solution. :-) .. Bruno Flückiger
Re: Strange ksh history behaviour
On 2013-01-07, Sébastien Marie semarie-open...@latrappe.fr wrote: What am I missing here? Can someone confirm this? You need to set your command-line editing mode to emacs. In order to keep EDITOR to vi, you should set VISUAL to emacs in your .profile: VISUAL=emacs EDITOR=vi export VISUAL EDITOR Many programs prefer VISUAL over EDITOR, so this is only of limited help.
Re: Strange ksh history behaviour
* Anthony J. Bentley anth...@cathet.us [130107 18:44]: Stefan Sperling writes: On Mon, Jan 07, 2013 at 02:09:01PM +0100, Lars von den Driesch wrote: However, I like vim and as soon as I set the EDITOR env variable to it the arrow up/down functionality is gone. In fact even if EDITOR is set with export EDITOR= the functionality is gone. Commands typed in still appear in the history using fc -l. I just cannot use the arrow-keys. What am I missing here? Can someone confirm this? It's a silly ksh misfeature. ksh switches to vi editing mode as soon as vi is set as an editor. Well, that's one part of the problem. The other issue is that arrow keys don't work in vi mode even though they probably should. I made a hack (vt220-compatible only) for anyone interested: http://plhk.ru/trash/ksh/0008-ksh-vi-arrow-keys-support.patch More funny diffs at http://plhk.ru/trash/ksh/ -- Alexander Polakov | plhk.ru
Re: Strange ksh history behaviour
Hi, On Mon, Jan 7, 2013 at 2:54 PM, Sébastien Marie semarie-open...@latrappe.fr wrote: It is the documented behaviour in ksh(1) :-) You could see the EDITOR variable comment in ksh(1): Well, what can I say :-) It was late and I was tired or my english is crap and didn't understand... ;-) EDITOR If the VISUAL parameter is not set, this parameter controls the command-line editing mode for interactive shells. And as arrow-keys are not used by the 'vi'-like command-line editing... What am I missing here? Can someone confirm this? You need to set your command-line editing mode to emacs. In order to keep EDITOR to vi, you should set VISUAL to emacs in your .profile: VISUAL=emacs EDITOR=vi export VISUAL EDITOR Thanks, a lot for the help. This really solved it. Who would have guessed - one more time where the man pages proved to be right :-D Again, thanks for the help Lars
Re: Strange ksh history behaviour
On Jan 07 14:36:53, s...@spacehopper.org wrote: On 2013-01-07, Sébastien Marie semarie-open...@latrappe.fr wrote: What am I missing here? Can someone confirm this? You need to set your command-line editing mode to emacs. In order to keep EDITOR to vi, you should set VISUAL to emacs in your .profile: VISUAL=emacs EDITOR=vi export VISUAL EDITOR Many programs prefer VISUAL over EDITOR, so this is only of limited help. e.g. mutt: EDITOR Specifies the editor to use if VISUAL is unset. VISUAL Specifies the editor to use when composing messages.
Re: Strange ksh history behaviour
On Mon, Jan 07, 2013 at 05:56:00PM +0100, Jan Stary wrote: On Jan 07 14:36:53, s...@spacehopper.org wrote: On 2013-01-07, Sébastien Marie semarie-open...@latrappe.fr wrote: What am I missing here? Can someone confirm this? You need to set your command-line editing mode to emacs. In order to keep EDITOR to vi, you should set VISUAL to emacs in your .profile: VISUAL=emacs EDITOR=vi export VISUAL EDITOR Many programs prefer VISUAL over EDITOR, so this is only of limited help. e.g. mutt: EDITOR Specifies the editor to use if VISUAL is unset. VISUAL Specifies the editor to use when composing messages. I prefer vim in mutt so I just use: alias mutt='env EDITOR=vim mutt' Since this is on my remote server, I don't need anything else for EDITOR or VISUAL variables. You might or might not be able to use this method. Depends on what you are running that depends on those two variables. Did I mention that I asked earlier on list about same problem? I would search the lists for similar answers. Chris Bennett
Re: Strange ksh history behaviour
On 8 January 2013 03:56, Jan Stary h...@stare.cz wrote: e.g. mutt: EDITOR Specifies the editor to use if VISUAL is unset. VISUAL Specifies the editor to use when composing messages. If in vi mode and have set $VISUAL, it will be used when you press v to edit the commandline in an editor. At least it does on 5.1 with EDITOR=vi and VISUAL=mg (for testing's sake only) Probably best to learn one set of keys and use them in the shell as well. John
Re: Strange ksh history behaviour
I've been using a patch I made months ago. I haven't submitted it to tech@ since I believe people actually want to keep it. I can't post it at the moment because it's just on the CVS checkout and I have other ksh changes that I have to split first.