I have mapped CtrlV 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:
Use this minimal
.bash_profilethat replicates the problem:stty lnext ^- bind -x '"\C-v": "echo mapping works"'Start a Bash session.
Press CtrlV -> see the output
mapping works.Run
python3.Use
exit()or CtrlD to exit the REPL.CtrlV is back to its default behavior.
source ~/.bash_profilethe mapping still doesn't work?source ~/.bash_profilenow CtrlV correctly producesmapping works, how?
Why does starting/exiting the Python REPL affect my CtrlV 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?
Here's example output of running stty -a | grep lnext:
~ $ stty -a | grep lnext
lnext = <undef>; min = 1; quit = ^\; reprint = ^R; start = ^Q;
~ $ python3
Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
~ $ stty -a | grep lnext
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
~ $ source ~/.bash_profile
~ $ stty -a | grep lnext
lnext = <undef>; min = 1; quit = ^\; reprint = ^R; start = ^Q;
~ $ source ~/.bash_profile
~ $ stty -a | grep lnext
lnext = <undef>; min = 1; quit = ^\; reprint = ^R; start = ^Q;
Here is some information of my system, python3 is from python.org's installer, and bash is from Homebrew:
~ $ which python3
/usr/local/bin/python3
~ $ python3 --version
Python 3.8.2
~ $ which bash
/usr/local/bin/bash
~ $ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-apple-darwin19.4.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
~ $ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.5
BuildVersion: 19F101
Here is even more information about my system:
~ $ echo $BASH_VERSION
5.0.17(1)-release
~ $ lsof -p $$
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 78982 eero cwd DIR 1,5 1568 359056 /Users/eero
bash 78982 eero txt REG 1,5 991320 4660332 /usr/local/Cellar/bash/5.0.17/bin/bash
bash 78982 eero txt REG 1,5 1568368 1152921500312627066 /usr/lib/dyld
bash 78982 eero 0u CHR 16,2 0t3107 985 /dev/ttys002
bash 78982 eero 1u CHR 16,2 0t3107 985 /dev/ttys002
bash 78982 eero 2u CHR 16,2 0t3107 985 /dev/ttys002
bash 78982 eero 255u CHR 16,2 0t3107 985 /dev/ttys002
~ $ /usr/local/bin/bash -li
~ $
stty -a | grep lnextafter exiting from python and after the first and second sourcing of.bash_profile?alias-exit_2which willexitas well assource ~/.bash_profiletwice.stty saneis being running, but I don't know why :-/BASH_VERSION=5.0.16(1)-release. Perhaps some system file is sourced when the repl starts and/or exits (grep -l 'stty'~/.??*) ? Orenv | grep PYTHON` ?