You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed that the delete key does bit work (prints [P instead of deleting character) when I use ipython in st terminal with zsh shell. When I use the same terminal but in bash the delete key works fine!
st FAQ suggests adding tput smkx to .bashrc or lines below to .zshrc to fix the issue.
function zle-line-init () { echoti smkx }
function zle-line-finish () { echoti rmkx }
zle -N zle-line-init
zle -N zle-line-finish
Unfortunately this doesn't fix the problem in iPython. I actually had exactly the same problem with vanilla python prompt too but adding set enable-keypad on to my .inputrc fixed it for python. I believe ipython doesn't use readlines anymore.
The text was updated successfully, but these errors were encountered:
With bash, I have the same problem. Initially, the tput smkx workaround from the st-FAQ seemed to work, but it stops working when less, or a pager in IPython, is used, so is not really workable.
The st terminal is determined to send ^[[P instead of ^[[3~ if enable-keypad is not set in ~/.inputrc.
As IPython uses prompt-toolkit instead of readline and thus ignores ~/.inputrc, it receives the ^[[P sequence regardless. Here is a workaround to bind this to delete (adapted from here):
fromIPythonimportget_ipythonfromprompt_toolkit.enumsimportDEFAULT_BUFFERfromprompt_toolkit.filtersimportHasFocusdef_delete(event):
event.current_buffer.delete(count=event.arg)
# Register the shortcut if IPython is using prompt_toolkitip=get_ipython()
ifgetattr(ip, 'pt_app', None):
ip.pt_app.key_bindings.add('escape', '[', 'P',
filter=HasFocus(DEFAULT_BUFFER))(_delete)
Other key combos might be affected as well.
Should this be reported as a prompt-toolkit issue?
@mwageringel Yes, this is an issue with prompt-toolkit, not IPython. I'll leave this open just in case it turns out that it's just something that IPython needs to tell PT to support, but otherwise I think you guys should take it up to the PT issue tracker first.
I have noticed that the delete key does bit work (prints
[P
instead of deleting character) when I use ipython inst
terminal withzsh
shell. When I use the same terminal but inbash
the delete key works fine!st
FAQ suggests addingtput smkx
to.bashrc
or lines below to.zshrc
to fix the issue.Unfortunately this doesn't fix the problem in iPython. I actually had exactly the same problem with vanilla python prompt too but adding
set enable-keypad on
to my.inputrc
fixed it for python. I believe ipython doesn't use readlines anymore.The text was updated successfully, but these errors were encountered: