WIndows/iPython: my arrow keys are not scrolling through command history (python 3.6.5) - ipython

I am trying to use iPython 6.4.0 on my gitbash terminal (using python 3.6.5). The problem I am having is that the arrow keys don't seem to be working properly in iPython. When I press the up arrow key, it does not go through past commands; it instead moves up a line in the terminal. This is the same with the other arrow keys, where they just move through the terminal lines instead of the ^[[(letter) output. Anyone know of a way to fix this?
I'm sorry if this question is not very clear, I am very new to python.

I just encountered this.
The solution is to:
winpty ipython
As you need to use winpty to get things like readline working in programs.

Related

How can I turn off vim in terminal of Mac?

I was trying to setup Mongo DB Community on my Mac(m1).
I installed Home-brew first and followed the install instruction of the Mongo DB.
However I could not run the command brew and I found that it was the problem that I didn't set up the Path in the zshell. So I tried it with my terminal but It just got stuck in this here. I tried to escape it with the :wq, :q! commands and it works. but whenever I restart the terminal it goes right back to this screen not to main screen. How can I solve this problem? plz help :(
(Im trying to learning so I'm not familiar with the terminal and codes stuffs)
You are in this situation because you typed the wrong command in the terminal and I suspect it is because you copy-pasted it instead of typing it out.
Your command is helpfully spelled out in the title bar of the window:
$ vi ~/.zshrcexport PATH=/opt/homebrew/bin:
Judging by the content of the buffer, it is almost certainly truncated and the actual command was probably:
$ vi ~/.zshrcexport PATH=/opt/homebrew/bin:$PATH
So what's wrong with that command? Everything, actually.
For starter, it should have been:
$ vi ~/.zshrc
with ~/.zshrc being your shell's main configuration file.
Everything after that shouldn't be here.
Vim, which is the program providing the vi command, takes one or more filenames as arguments. With that command, you told Vim to open two files:
~/.zshrcexport
PATH=/opt/homebrew/bin:$PATH
the former is the one shown in your screenshot,
the latter is not shown but it is likely to have a rather long name,
neither of those files are supposed to exist.
How to get out of that mess?
Assuming you are in the situation shown by that screenshot, do the following:
Press the esc key to make sure you are in what is called "normal mode" in Vim.
Press the : key to enter "command-line mode".
Type qa!, then press the return or ↩︎ key.
At that point you should be outside of Vim and in your shell. It is time to delete the non-wanted files you created with these two commands, each followed by a press on the return or ↩︎ key:
$ rm ~/.zshrcexport
$ rm PATH=/opt/homebrew/bin:$PATH
Now you should finally be able to edit your shell's configuration file but I recommend you don't do it with the vi command. nano is a much simpler editor that doesn't require as much learning.
Open the configuration file in nano with:
$ nano ~/.zshrc
Move around with your cursor keys until you find the right spot, just like in a regular text editor. The file is probably empty anyway.
Type that "export" line:
export PATH=/opt/homebrew/bin:$PATH
Press control+X to quit, as instructed at the bottom of the screen.
Press the appropriate key when asked if you want to write the file.
Avoid vi or vim in the future until you actually have or want to learn it.
As for why you end up in Vim when you open a new terminal window I have no clue. Maybe another one of your mistakes?

Resize the terminal in vscode is trigger the ctrl+c to terminate the running command

I'm running the vscode 1.64.2 on Windows 10. Currently i met a strange problem, When i resize the terminal in the vscode and the cursor is focus on the terminal, Then it will trigger ctrl+c . At this time any running command would be terminated immediately .
To avoid this i have to un-focus for the terminal first and then resize it. Any suggestion here?
I was searching about this with no luck. Today I realized about one installed software on my machine that has a global hook on mouse selection. In my case was the QTranslate software. When I exit the application the problem was solved.
Check if you have this or another software that has a global hook on mouse selection.
In VS Code this problem (control C) was happening for any command line inside the terminal. Apart from that, opening Git bash (standalone) I was having the same issue, but not for cmd or another command line.
Hope this helps you because this was driving me crazy.
Absolutely working solution!
I experienced the same problem with mouse strange behavior for a long time, but finally I found out it was the QTranslate's guilt! After I stopped it, the problem has gone. (can't vote up because of my virgin profile here).
PS: I found the solution how to push work both QTranslate and terminal window - just set QTranslate setting "Advanced->Copy action" to "Ctrl+Insert" instead of Ctrl+C.

I am trying to use :g in Vim doesn't work "Command :g[lobal] is not yet implemented" i get in the status line

I wanted to try vim for a bit, and get used to it... i got stuck with trying to replicate Ctrl+D functionality of VScode... so I've tried couple Google solutions.
This is What I've tried when I got that error:
:g/oldword/norm newword
I see lots of people do search patterns like this, but it's annoying I get this message, without being able to find solution on google :D
I know I can solve this issue with /word then cgn newword and then just repeat with . operator, BUT, I want to be able to use the global command for searching patterns and stuff, for other purposes too, and it stresses me out that I can't make it work!
Here is the error I am getting.
Any help is extremely appreciated / welcome! Thanks.
Edit: Forgot to mention: We are talking about Vim for VScode, not the gvim installation stuff. Will try to install that too, and update the question.
Edit2: Okay so apparently, after instalilng gvim (from official site) and ran it through vim command in cmd prompt, the official vim can run the :g commands.
Like (for example) if you want to search for <a> and replace it with <router-link> you can do so by: :g/<a>/norm ciw<router-link>
Which means:
:g/<a>/norm run a global (file) search for pattern <a>
ciw - change in word
<router-link> the replacement pattern for <a>
Note: The same should be done for </a> after that :D
The problem still exists tho.
While the native vim exe (outside of vscode) works and can run these stuffs, I still need to fix the vscode one (the extension that is). It is defo nice to have syntax highlighting and correction.
What you are using is not Vim. It is a Vim emulator which, like all Vim emulators, can't be expected to be either complete or accurate. Its only relationship with Vim is that it tries and fails to imitate it.
Some of the Vim stuff you will find on the internet will work in that VSCode extension exactly as it does in Vim, some of it will work but partially or differently, and most of it, like :g, will simply not work.
There is nothing you can do about that except, maybe, contributing to the project.
If you want support for the global command in VSCode, install Neovim and the VSCode extension for it:
for those who expected this to work but it doesn't, it's possibly because you need to have installed neovim (firstly) and then vscode-neovim extension (secondly) https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim
Source: https://github.com/VSCodeVim/Vim/issues/2346
The easiest way to get this working is to enable neovim in the VS Code Vim extension you're using.
Once you have installed Neovim on your operating system, you can enable it within VSCode inside the Preferences: User Settings window:
Enable the Vim: Enable Neovim option (vim.enableNeovim)
Set the path to Neovim inside the Vim: Neovim Path setting (vim.neovimPath)
Restart VSCode
Source: https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim/integrating-vscode-with-neovim/#enabling-neovim-inside-vscode

backspace does not work git bash

The first time I used git bash, backspace was working fine. Then I installed Perl and didn't use git bash for a few days.
When I use backspace in git bash now it doesn't work correctly.
For example, trying to remove the second s and everything after it in ussers:
Now when I use the backspace this happens:
Can anyone help?
I had this same problem today after switching to mintty with a fresh version of git. In my case, it was an old .bashrc file I'd been carrying around for many years with the line export TERM=ansi. After removing that and starting a new bash, everything works again.
More generally, to debug, I was suspicious of all the dot-config stuff in my home directory--so I moved things like .bash_profile, .bashrc, .inputrc, etc. into a temporary directory where they wouldn't be read by bash. Then, I started bash and saw that it worked. I mention it because, if it isn't specifically the TERM issue I had, you might be able to debug using the same technique.
Not sure if this is the same issue.. But I ran into the same after upgrading git
This helped me.. Just enter TERM=XTERM in the bash
I got this from an issue log in github..
screenshot
Just in case people run into a capitalization issue please type TERM=xterm-256color directly into git bash and hit enter. This fixed my issue.
Right click on the menu/title bar of git bash, select options, click on terminal from the options on the left, under the 'type' dropdown, select 'xterm', then apply and save.
Now open a new git bash and it should work :D

Filtering ZSH history by command

I was told that in ZSH you could do something like command and then when you hit up it would filter the history based on the given command. But when I try this it just cycles the history like bash does. Is this disabled by default?
Hit Ctrl+R, type some letters, it will find the previous command with these letters, keep hitting Ctrl+R to continue through the previous findings.
Works in bash, zsh (and other shells i suppose).
What i personally like to have is: type some letters, press Up, the previous commands starting with the same letters appear. Very powerful, i love it.
You have to bind the keys you want to history-beginning-search-backward and history-beginning-search-forward.
In case it's not enough for you, zsh has a lot of options, try to look in Zsh Line Editor and tell us.
For bash, less powerful but more common, Bash commands for history.
Use exclamation point:
> !<starts-with this string>
You can arrow up/down through all commands that started with that. I use "!v" all the time to get my previous command for opening a file with Vim.
You can also use a question mark to search beyond matching the beginning of the string,
> !?status
Can find "git status".
Use percol to dynamically search and navigate through your history with Ctrl-r.
install percol: sudo pip install percol
add the zsh-history-search code snippet to your .zshrc file.
After a Ctrl-r, you can see your whole history in the same window. Searching for a keyword (dynamically) narrows that list down. You can use key-bindings (like this emacs like config) to navigate up and down the list and eventually make a selection.
Here is a search for all sudo install commands available in history with sudo make install selected.
Enter issues the selected command.
We can also use fzf to fuzzy search the command history interactively.
Here is how to install:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
Say yes to all its configs. After that, restart your zsh shell, and press Ctrl-R, whoa, interactive command history search pops up. Enjoy!
With the vim keybindings activated in zsh you can use vi-history-search-backward (/) when in vi command mode.
That's a feature available in fish, but it seems like someone made a zsh plugin for it. It's not available in standard ZSH.
If you don't want to add any keybindings, you can search by default using Ctrl+R to move backward & Ctrl+S to move forward.
You can start search with any of the key shortcuts Ctrl+R or Ctrl+S