1

when I press CTRL+/, it seems to have the same outcome as the shortcut CTRL+U, which deletes before the cursor until the start of the command.

Does anyone know of CTRL+/ in Linux?

4
  • 1
    Run the command od -t x1z, then press Ctrl+/, then press Ctrl+D. You should get a hexadecimal representation of the character(s) generated for the Ctrl-/ keystroke by your keyboard layout and terminal emulator configuration.
    – telcoM
    May 20, 2023 at 0:17
  • 1
    It's not necessarily the same outcome. In my Kubuntu, if I press Up to get a line from history and I append something, and I press Ctrl+/ then it will delete what I appended. Ctrl+u would delete everything. May 20, 2023 at 3:41
  • Wow! bash have Undo! Try to edit your command and then press Ctrl+/. It works like Ctrl+Z in text editors.
    – yarolig
    May 20, 2023 at 7:34
  • @telcoM od isn't always a good tool to debug such issues, as it doesn't see the bytes handled by (or altered by) the kernel's tty driver. For example Ctrl+U removes the line rather than reporting its generated byte 21. Use showkey -a instead.
    – egmont
    May 20, 2023 at 8:22

2 Answers 2

2

Ctrl-/ seems to generate the same character code as Ctrl-_ (control underline). In Bash, this is the keybinding for undo.

The ASCII character generated is US (unit separator), whose code is 31 or hex 1F.

The reason it seems to have the same effect as Ctrl-U is that you typed some input and it's just undoing that. Try typing some input, then backspacing over some of it and then using Ctrl-_.

This is not a "Linux" behavior. In an actual Linux VGA console on an Intel machine, Ctrl-/ produces the DEL characters, 127. That character is often notated ^?, so it makes sense that way. Bash interprets it as a backspace.

14
  • 1
    It is a mistake to assume that all keyboard layouts and terminal emulators produce the same ASCII characters on that keystroke. For example, on this Mac with a Finnish keyboard layout, connected to a Debian 11 system over SSH, Ctrl-/ just causes the terminal emulator to beep without passing any input to the shell.
    – telcoM
    May 20, 2023 at 0:07
  • @telcoM The DEC VT100 manual says that Ctrl plus the shifted or unshifted ? key produces the US character. If that doesn't happen, your terminal emulator not quite faithfully emulating a VT100. vt100.net/docs/vt100-ug/chapter3.html (I'm not getting the right behavior when Shift is used.)
    – Kaz
    May 20, 2023 at 0:15
  • Even a Xterm is not 100% faithful to a DEC VT100, so unless the question was about retrocomputing, you are stating a vacuous truth. Also, you're assuming a US English keyboard layout.
    – telcoM
    May 20, 2023 at 0:19
  • @telcoM I tried it in Slovak and Japanese. Same result. Now various keys are mapped quite differently; for instance Y and Z are exchanged in the Slovak layout. (And so are Ctrl-Z and Ctr-Y!) Firstly, does the unmodified / key produce a slash in your Finnish layout? In Slovak mode, / produces a hyphen -. Yet Ctrl-/ is still ASCII US. It's not obvious what Ctrl-/ has to do, or should have to do with language.
    – Kaz
    May 20, 2023 at 0:52
  • 1
    @egmont Same result: immediate beep and a zero-length file after I press Ctrl-D to terminate the redirection. I assume we are both in agreement about macOS terminal being weird.
    – telcoM
    May 20, 2023 at 8:40
0

The bash/readline emacs-style keybinding list is poorly documented,however the source shows that there is no readline/bash keybinding specifically for C-/.

Instead the scancodes for various keyboards are mapped to keycodes which are in turn mapped to a characters. The utility 'showkey' shows this clearly. On my US keyboard both for C-/ to the same character as C-. So bash has one binding for C- (to undo) and has no ability to distinguish the differnet keyscans that generate this same character.

https://tiswww.case.edu/php/chet/readline/rluserman.html

man 1 showkey

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .