LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   explain variations in terminal behaviour? (https://www.linuxquestions.org/questions/linux-software-2/explain-variations-in-terminal-behaviour-796370/)

gearoid_murphy 03-18-2010 04:28 PM

explain variations in terminal behaviour?
 
Hello all, I use many different terminals during the course of my working day and frequently have to adjust my interaction to each unique type. For example, when interacting with bash via my work gnome-terminal I can use ctrl-arrow to skip over words, like most test editors allow. On the other hand, my xterm at home can't interpret this action and spits out a chunk of binary gibberish whenever I use this command. I think that the behaviour of bash is consistent, it's just that the xterms treat keyboard events differently, depending on their configuration. Can someone confirm for me that this correct?, if yes, how can I calibrate the terminal to treat my keystrokes in the manner I desire?, thanks.

GrapefruiTgirl 03-18-2010 04:37 PM

Much of the stuff you describe is determined by two things, which work together:

1) the $TERM environment variable, which is set by the terminal program when it starts.
2) the /etc/inputrc file, which contains readline bindings/translations for those 'gibberish' keycodes you see.

You can create your own ~/.inputrc file, and use the $include directive to include the system one located at /etc/inputrc. This can allow you to customize actions for those 'gibberish' characters. NOTE: The actual shell you are using (Bash, Dash, Ash, whatever) must also be capable of understanding and dealing with the codes you configure (specifically something like "history" which AFAIK only works for Bash; the usual stuff, like going to the end of a line, or skipping words, should work for most modern terminal programs), but as yet, I have not encountered a keycode that doesn't work properly after having configured it in my ~/.inputrc file.

The procedure:

1) open the terminal that gives you gibberish upon certain keystrokes;
2) press CTRL-V
3) Now, press the key stroke that you wish to configure.
4) Note the gibberish.
5) open your /etc/inputrc or ~/.inputrc file and add an entry for the gibberish (use etc/inputrc as a template of examples)
6) Now that keycode will work properly in that terminal.

Hope this helps :) but if there's stuff I left out (and there probably is a lot more to this) just ask, or explain what's not working.

Sasha

PS - after having saved you new items in the inputrc file, you may have to reboot, logout, or source the /etc/profile file, for the settings to take effect sooner than later. The inputrc file and its environment variable are set during bootup, by an entry in /etc/profile (at least on my Slackware system -- it *might* vary for other Linuxes.)

gearoid_murphy 03-19-2010 03:51 PM

many thanx GrapefruiTgirl!, very detailed instructions, the best kind ;-), I haven't tried them out yet cos I'm knackered but I'll post again when I've more to report....

GrapefruiTgirl 03-19-2010 04:09 PM

To further help you when you get to this, here's the file I created as my ~/.inputrc file. I have highlighted the $include directive, which "includes" the system-wide file, and then appends my own additions. The reason for this, is that if/when your system-wide version of the /etc/inputrc file ever gets replaced or updated, your additions won't be lost; they remain in your ~/.inputrc file.
Code:

# ~/.inputrc
# This file configures keyboard input for programs using readline.
# See "man 3 readline" for more examples.

$include /etc/inputrc


# Sasha added 7 and 8 here to make Home and End
# keys work in Eterm and Rxvt terminals.

"\e[7~": beginning-of-line
"\e[8~": end-of-line

# notes to self:
# need to check all terminals for correct function of
# all keys; when all good, copy this over for root too.


Sasha


All times are GMT -5. The time now is 05:48 AM.