macOS:Catalina 10.15.7 python:3.8.5 VScode:1.50.1
When I press the arrow keys when executing python on the terminal of VScode, "^ [[A ^ [[B ^ [[C ^ [[D" is entered, and I have to enter the value once in the past again. I had to.
python
^[[A^[[B^[[C^[[D
This time, we will avoid this problem by introducing "rlwrap". We will use "homebrew" for installation, but this time we will omit the installation of "Homebrew". (Because there are already many articles about installing Homebrew.)
First, search for "Terminal" with "command + space" and start Terminal. Then enter the following.
python
brew install rlwrap
If there is no problem, "rlwrap" should be installed, so check if it was installed normally.
python
$ rlwrap -v
rlwrap 0.43
It's okay if the version is displayed like this.
After that, when running python
python
$ rlwrap python a.py
Just add to the front! (I haven't tried it in languages other than python, so I don't know! sorry! )
Only for those who use VScode, but I will introduce it because there are convenient settings.
First, install the extension "Code Runner". This extension makes it very easy to execute a supported language by pressing the play button or using a shortcut key.
Once installed, click on the gear symbol and select "Extention Settings" at the bottom. Next, I think there are "User" and "Workspace", Check "Run in Terminal" in "User".
Then select "Workspace". Then click "Edit in settings.json" in the "Code-runner: Executor Map" column.
If you look in the opened settings.json, you will find the following code.
settings.json
"python": "python -u",
Rewrite this as follows and save it.
settings.json
"python": "rlwrap python -u",
By doing this, "rlwrap" will be added automatically when you execute python with "Code Runner", so you do not have to enter it every time.
Recommended Posts