Skip to main content
expanded (customization, usage notes)
Source Link
arielCo
  • 1.1k
  • 8
  • 12

In Bash and the Korn shell (Emacs mode) Esc-# is like putting a # at the beginning and pressing Enter:

Example:

$ find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl

(Esc-  #) ;

$ #find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl
$ _

Works inNotes

1: In some terminals, Alt+whatever as a chord is another way of sending Esc followed by whatever

2: # means whatever you need to press to get a '#' so you might have to press Esc then Shift+3 or Alt+Shift+3

(thank you @vi)

Customization

In Bash, you can control the prefix by adding a line like this to .inputrc:

set comment-begin "## "

(The quotation marks are only necessary if you have leading or trailing blanks)

You can also set another binding and unbind the Korn shell.default Esc-#:

"\e'": insert-comment
"\e#": nop

https://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html

Esc-# is like putting a # at the beginning and pressing Enter:

Example:

$ find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl

(Esc-#)

$ #find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl
$ _

Works in Bash and the Korn shell.

In Bash and the Korn shell (Emacs mode) Esc-# is like putting a # at the beginning and pressing Enter:

Example:

$ find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl

Esc  # ;

$ #find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl
$ _

Notes

1: In some terminals, Alt+whatever as a chord is another way of sending Esc followed by whatever

2: # means whatever you need to press to get a '#' so you might have to press Esc then Shift+3 or Alt+Shift+3

(thank you @vi)

Customization

In Bash, you can control the prefix by adding a line like this to .inputrc:

set comment-begin "## "

(The quotation marks are only necessary if you have leading or trailing blanks)

You can also set another binding and unbind the default Esc-#:

"\e'": insert-comment
"\e#": nop

https://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html

added 269 characters in body
Source Link
arielCo
  • 1.1k
  • 8
  • 12

Esc-# worksis like putting a # at the beginning and pressing Enter:

Example:

$ find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl

(Esc-#)

$ #find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl
$ _

Works in Bash, and the Korn shell.

Esc-# works in Bash, Korn shell.

Esc-# is like putting a # at the beginning and pressing Enter:

Example:

$ find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl

(Esc-#)

$ #find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl
$ _

Works in Bash and the Korn shell.

Source Link
arielCo
  • 1.1k
  • 8
  • 12

Esc-# works in Bash, Korn shell.