pmo
pmo

Reputation: 23

"Q" key does not work in MacBook Pro's Terminal despite working in all other programs

A little while back the "Q" key on my keyboard inexplicably stopped working in my Terminal. It works in all other places but if I type it in the Terminal nothing shows up; if I copy and paste that contains a "Q" character the "Q" gets omitted. For instance, if I copy "quote" and paste it into the terminal, it displays the following:

cs9e-1aj@hive12 [125] ~ # uote

If a existing file contains the "Q" character in its filename and I tab-complete, the "Q" character does show up. I'm just now in the process of learning Unix and I'm not able to find any information as to what might be going on. Does anyone know what may have happened? Is there any way to check if the key got remapped? Thanks!

Here is the output of "stty -a":

speed 9600 baud; 24 rows; 80 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
    -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
    -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = q; time = 0; werase = ^W;

Upvotes: 2

Views: 664

Answers (1)

andrewdotn
andrewdotn

Reputation: 34813

stty is an ancient Unix command for configuring the operating system to work with your terminal, whether it be a VT100, an IBM 3486, an ICL 7561, or one that you built yourself in your garage.

enter image description here enter image description here enter image description here

(last image by Andrew Filer)

Before CRTs and bitmap graphics, these things talked to your computer over a serial line. You’d use the stty command to set things like baud speed, how many stop bits and parity bits to use in the serial protocol, and what control characters from the terminal should be bound to specific actions like backspace or end-of-file.

And somehow your newfangled “software terminal emulator” is being configured with susp = q, which means that the terminal is treating the q input key press as a control character to suspend the current process. Try it by starting a lengthy process and pressing q where you would normally press CtrlZ

$ curl -LO 'http://softlayer-ams.dl.sourceforge.net/project/systemrescuecd/sysresccd-x86/4.0.1/systemrescuecd-x86-4.0.1.iso'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0q
<q>
[1]+  Stopped                 curl -LO 'http://softlayer-ams.dl.sourceforge.net/project/systemrescuecd/sysresccd-x86/4.0.1/systemrescuecd-x86-4.0.1.iso'
Returned 146 (SIGTSTP).

Instead of the letter q, the STOP signal gets sent to the process.

To fix this:

  • Find where in your dotfiles there is a command like stty susp q; hopefully you can find this with grep stty ~/.*.
  • Otherwsie, reset it to the normal value by adding

    stty susp ^Z
    

    to your ~/.bashrc. Note that that’s a literal ^ caret followed by a literal Z character, not an actual ^Z control character.

Upvotes: 3

Related Questions