How can I Interrupt (intr) a command with a key other than Ctrl+C?

When you want to abort a command running on a remote server, you usually use the Ctrl+C key combination. To verify how the command interrupt (intr) key is set in the current user environment, run the stty command.

In the server above, you can see that Ctrl+C (^C) is the key being used to abort the current command.

The following will guide you on how to send an intr signal using different keys in Xshell.

How to set different key combinations using the stty command

$ stty intr CHAR

You can set different Ctrl key combinations in CHAR. For example, if you want to set the Ctrl+A key:

$ stty intr ^A

The ^A character is a single character that appears by pressing Ctrl+V, Ctrl+A consecutively.
Some systems accept the two characters ^ and A as Ctrl+A. You can also recognize ASCII code number 1 of Ctrl+A by presenting it as an octal (\001) or hexadecimal value (\0x01).

$ stty intr \001

 

How to use Xshell’s custom key mapping function

  1. Select ‘Options’ from the [Tools] menu.

  2. In the ‘Keyboard and Mouse’ tab, click ‘Edit’ to launch the ‘Custom Key Mapping’ dialog box.

  3. Click ‘New…’ and press the desired key combination in the Enter key combination box.
    NOTE: Keys that do not appear in this box cannot be used for custom key mappings.

     

  4. As an example, let's try the Ctrl+Shift+C key combination.

     

    • Type: Select Send String.

    • String: We’ll need to specify the code value of the character assigned to intr in the server's user environment. If intr was ^C in the result of the stty -a command, enter the ASCII code value 3 of ^C as octal ‘\003’ or hexadecimal ‘\x03’.

  5. Press ‘OK’ to save the key combination settings.

  6. Confirm that Ctrl+Shift+C in the Terminal will interrupt (intr) a running command.