I don't know what terminal the OP is using - probably the built-in terminal (Terminal.app), but in case anyone has this problem with iTerm2, here is what fixed it for me:
In iTerm2 Preferences > Keys > Navigation Shortcuts > "Shortcut to choose a split pane" was opt+number
, so opt+3
was mapped to focus the 3rd pane in your tab had been split into panes, but this was overriding the normal mapping of opt+3
to #
. I changed it to "No shortcut" and could then type hash symbols in iTerm.
I never had this problem before, but recently bought a new MacBook Pro M1 with MacOS Monterey, installed iTerm2 on it amongst other things, and then was was amazed to find that I couldn't type a hash symbol in the terminal - for example, for making comments in Python code or Bash scripts. I certainly didn't set it that way - so it must have been in the default setup of iTerm2. Why on earth the developers thought that was a good setting to have on by default, I don't know.
alt-3
, e.g. in a text editor? Does it work inbash
; is the error just happening innano
? If you enterread
in bash, press enter, then pressalt-3
, what happens?alt
is also used as modifier for keyboard shortcuts.Shift-3
for the pound character£
.alt
key, maybe it'sAlt-Gr
and changes things?