Date: Tue, 29 Dec 2015 23:26:22 +0100 From: Bertram Scharpf <lists@bertram-scharpf.de> To: freebsd-questions@freebsd.org Subject: Re: delete button in console Message-ID: <20151229222622.GA18290@becker.bs.l> In-Reply-To: <5682F182.7080603@hiwaay.net> References: <56825701.30908@gmail.com> <20151229180750.187ed7c9.freebsd@edvax.de> <5682F182.7080603@hiwaay.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, On Tuesday, 29. Dec 2015, 14:53:32 -0553, William A. Mahaffey III wrote: > On 12/29/15 11:14, Polytropon wrote: > > On Tue, 29 Dec 2015 01:48:49 -0800, Sergei G wrote: > >> When I ssh to a FreeBSD machine and press 'Delete' button in csh prompt > >> I get character '~' printed on screen. Backspace works just fine. > >> > >> I think even an actual console behaves the same way. > >> > >> Is there a way to "map" the Delete button to work appropriately? Would > >> it be my SSH client application or FreeBSD itself? > > This is a thing that can be configured for the shell. I assume > > you're using FreeBSD's default dialog shell, the C shell. In > > this case, add to ~/.cshrc: > > > > bindkey ^? delete-char # for console > > bindkey ^[[3~ delete-char # for xterm > > > > Or to /etc/csh.cshrc, if you want to make it a global setting. > > > > You can check the success with the "stty -a" command. > > Is this keyboard dependent ? My keyboard apparently sends '^?' for its > backspace key. When I try the above, then 'stty -a', I see no setting. I cannot see what stty should have to do with it. stty's "erase" and "erase2" do only work when icanon is set. Unfortunately "stty -a" yields wrong results because the shell changes the parameters before entering the "stty" program. To determine the true values, do the following. $ tty /dev/pts/5 Here, 5 could be any number depending on what was allocated when the emulator window was started. Then open another terminal and ask there: $ stty -a -f /dev/pts/5 Of course, replace the 5 by the right number. You will see a "-icanon". Notice the minus in front of the property. That means every key pressed will be passed to the command line editor immediately. If icanon is on, the line must be completed by pressing enter or return (^M) and after that the characters will be passed to the input-processing program. In this mode the backspace (^H) deletes characters and the input routine will not be aware they were pressed at all. "delete-char" is a csh function (man csh). Probably there is something like delete-char-to-left that will be executed on backspace (^H). I did not find it. In Zsh its name is "backward-delete-char". By the way, you can explore the escape codes produced by arrow keys etc. using the dd program. Just say $ dd and play around with the Ins/Del/Home/End/Fx etc. keys. As long as dd runs, icanon is set. Convince yourself of that by executing the above stty command again. Leave dd by pressing Ctrl-C. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20151229222622.GA18290>