tutorial icon indicating copy to clipboard operation
tutorial copied to clipboard

Can't type "~" on pythonanywhere bash

Open username1290 opened this issue 8 years ago • 14 comments

Cant type the "~" symbol in the bash command line (step needed at the django deploy chapter, section: install) any ideas?

username1290 avatar Sep 09 '16 21:09 username1290

I've had the same issue trying to type a "@" on Windows 10 with a french AZERTY keyboard layout. In the end this wasn't strictly necessary so I managed to bypass the issue.

Perhaps try typing ~ somewhere else, then copy and paste it into the PythonAnywhere bash console?

thibaudcolas avatar Sep 19 '16 14:09 thibaudcolas

Hi man, thought about that but found no way to paste text inside bash. I also had a hard time typing "@" on a OSX Spanish ISO keyboard.

Finally I: 1.- skipped typing "~", so it installed latest version, not the one in the tut, and 2.- Added USA keyboard, and after some fiddling found the "@", but this was very cumbersome

username1290 avatar Sep 19 '16 14:09 username1290

We had the same issue with both "~" and "@" with a Swiss QWERTZ keyboard on OS X. As a workaround we skipped the "~" when installing Django by specifying the version directly (i.e. django==1.9.9). And when creating the superuser we just left the e-mail field blank since we could not enter the "@" symbol. Copy and pasting worked for one of the participants, but not the other.

sykaeh avatar Sep 26 '16 16:09 sykaeh

I have looked around the PythonAnywhere forums and it is a known issue: https://help.pythonanywhere.com/pages/TypingProblemsInternational/

I've been testing this by moving back and forth between french AZERTY and US QUERTY layouts in OSX (there is an "Input sources" setting for that in the OSX Preferences). In AZERTY, I can't enter any of the characters that require the alt key pressed – @ being one of them. I can imagine this affects a lot of keyboard layouts, and I'm surprised this hasn't come up sooner for Django Girls.

PythonAnywhere seems to be using https://github.com/macton/hterm, I've had a look around but haven't found anything too conclusive. This is where I would dig next to fix the underlying issue: https://github.com/macton/hterm/blob/master/src/hterm_keyboard_keymap.js#L191.

thibaudcolas avatar Sep 26 '16 18:09 thibaudcolas

thanks for the detective work, created an issue in hterm: link

username1290 avatar Sep 28 '16 00:09 username1290

I have found https://bugs.chromium.org/p/chromium/issues/detail?id=211925, which seems to say that a fix/workaround has been found.

Here is the version of hterm that is still maintained: https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm, and there is a FAQ about "typing accented characters" which I think might be relevant to us:

How do I enter accented characters?

You should manage your preferences under the Secure Shell Options page. Just right click the app in Chrome, select Options, and see the Keyboard section. The documentation below is meant for people hacking on the source directly.

That depends on your platform and which accented characters you want to enter.

In xterm, you could use Alt-plus-a-letter-or-number to select from the upper 128 characters. The palette of 128 characters was “hardcoded” and not dependent on your keyboard locale. You can set hterm to do the same thing by opening the JavaScript console and typing...

term_.prefs_.set('alt-sends-what', '8-bit') However, if you are on Mac OS X and you prefer that Alt sends a character based on your keyboard locale, try this instead...

term_.prefs_.set('alt-sends-what', 'browser-key') Note that composed characters (those that require multiple keystrokes) are not currently supported by this mode.

If you are running Chrome OS on a Chromebook you can select your keyboard locale from the system settings and just use the Right-Alt (the small one, on the right) to enter accented characters. No need to change the ‘alt-sends-what’ preference at all.

The default value for ‘alt-sends-what’ is ‘escape’. This makes Alt work mostly like a traditional Meta key.

If you really, really want Alt to be an alias for the Meta key in every sense, use...

term_.prefs_.set('alt-is-meta', true)

I have tested this successfully in PythonAnywhere. To do so you need to go to one of their consoles (eg. a Bash one), then open the Chrome DevTools, in the DevTools Console move from the "top" origin to the "console" one, and enter the following:

window.Anywhere.terminal.prefs_.set('alt-sends-what', 'browser-key')

Note that this value is persisted in LocalStorage between page reloads. If you want to reset it you will need to remove the preferences in LocalStorage ("Application" tab of the DevTools, Storage > Local Storage > https://wwww.pythonanywhere.com).

With this configuration, I am able to enter most special characters successfully with the US QWERTY and FR AZERTY input sources on Chrome/OSX. I haven't tried other browsers.

Some caveats:

  • I still wasn't able to type a ˜ in the AZERTY layout
  • I don't fully understand the implication of those configuration options, and whether it would be possible to change the default for everyone's benefit.

Can other people give this a try as well, see if it makes a difference in other locales/browsers/OSes?

thibaudcolas avatar Oct 01 '16 11:10 thibaudcolas

(How to use literal `~` in MarkDown/GitHub comments) @sykaeh In GitHub comments (and other MarkDown source) escape the tilde character with a backslash (`\~`) to preserve its literal meaning. (Enclosing text in `~` will strike it through when rendering MarkDown.)

So

We had the same issue with both "\~" and "@" with a Swiss QWERTZ keyboard on OS X.
As a workaround we skipped the "\~" when installing Django by specifying the version directly
(i.e. `django==1.9.9`).

will display correctly as

We had the same issue with both "~" and "@" with a Swiss QWERTZ keyboard on OS X. As a workaround we skipped the "~" when installing Django by specifying the version directly (i.e. django==1.9.9).

instead of

We had the same issue with both "~" and "@" with a Swiss QWERTZ keyboard on OS X. As a workaround we skipped the "~" when installing Django by specifying the version directly (i.e. django==1.9.9).

das-g avatar Feb 07 '17 22:02 das-g

We had the same issue with both "~" and "@" with a Swiss QWERTZ keyboard on OS X.

I also just experienced this issue with a Swiss QWERTZ keyboard on Ubuntu. Copying the tilde from the tutorial page to the secondary clipboard (select it and Ctrl-c) and pasting it in the PythonAnywhere bash console (with Ctrl-v) worked as a workaround, though. (Copying it to the primary clipboard by just selecting it and then pasting it on PythonAnywhere with middle mouse button didn't work though).

das-g avatar Feb 07 '17 22:02 das-g

@das-g Thanks for the tip. I hadn't noticed that it wasn't displaying properly. I have now corrected it.

sykaeh avatar Feb 08 '17 02:02 sykaeh

This happened again in February 2017 on a Mac (where using Chrome instead of Safari fixed it) and also in October 2017 (in some cases copy-pasting a ~ from a text editor did work, in some other cases it didn't).

pts avatar Oct 16 '17 13:10 pts

@pts which keyboard layout was used when you could reproduce it?

ekohl avatar Oct 16 '17 13:10 ekohl

@ekohl: Unfortunately I don't remember any more details exactly. With high probablilty the keyboard layout was Swiss German. It could as well be regular German.

pts avatar Oct 16 '17 13:10 pts

I just had a student with a german keyboard layout who couldn't type the @ either so I can confirm this can be an issue. She was also using a Mac with Safari.

ekohl avatar Nov 04 '17 10:11 ekohl

https://www.pythonanywhere.com/forums/topic/1839/ has a suggestion but when I tried it I got an error that Anywhere.terminal was undefined so maybe it's outdated.

Edit: I think those are chrome instructions, not safari.

ekohl avatar Nov 04 '17 11:11 ekohl