#StackBounty: #bash #terminal #keyboard-shortcuts Why does exiting Python REPL clear my Ctrl-V Bash mapping?

Bounty: 50

I have mapped Ctrl-V in my .bash_profile to a function that opens a file in Vim using fzf. It works perfectly, but whenever I exit from the Python REPL the mapping doesn’t work until I source my .bash_profile twice or start a completely new shell session.

Steps to reproduce:

  1. Use this minimal .bash_profile that replicates the problem:
stty lnext ^-
bind -x '"C-v": "echo mapping works"'
  1. Start a Bash session.

  2. Press Ctrl-V -> see the output mapping works.

  3. Run $ python3.

  4. Use exit() or Ctrl-D to exit the REPL.

  5. Ctrl-V is back to it’s default behavior.

  6. $ source ~/.bash_profile the mapping still doesn’t work?

  7. $ source ~/.bash_profile now Ctrl-V correctly produces mapping works, how?

Why does starting/exiting the Python REPL affect my Ctrl-V mapping (this does not happen to my other mappings)? And why do I need to source my profile twice for the mapping to start working?

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.