'enable vi command line editing from .perldb rc afterinit in perl debugger
Whenever I start the perl debugger from a script with a -d option, the session starts with emacs command line editing. I then type ESC ctrl J to enable vi editing. I want to enable vi from the get-go.
I tried using the following .perldb:
&parse_options("HistFile=.perlDebugHist");
sub afterinit { push @DB::typeahead, ("o inhibit_exit", chr(27).chr(10)) }
but when the session starts, it says
auto(-2) DB<62> o inhibit_exit
inhibit_exit = '1'
auto(-1) DB<63>
Unrecognized character \x1B; marked by <-- HERE after :db_stop;
<-- HERE near column 96 at (eval 9)[/usr/share/perl/5.22/perl5db.pl:737] line 2.
at (eval 9)[/usr/share/perl/5.22/perl5db.pl:737] line 2.
eval 'no strict; ($@, $!, $^E, $,, $/, $\\, $^W) = @DB::saved;package main; $^D = $^D | $DB::db_stop;
;
' called at /usr/share/perl/5.22/perl5db.pl line 737
DB::eval called at /usr/share/perl/5.22/perl5db.pl line 3110
DB::DB called at ~/bin/debug.pl line 61
Solution 1:[1]
Here is a possible workaround that assumes you use the gnu readline library:
Create a file called perldb_inputrc
in the current directory with content:
set editing-mode vi
Then change the afterinit()
sub to:
sub afterinit {
if (!$DB::term) {
DB::setterm();
}
$DB::term->read_init_file('perldb_inputrc');
push @DB::typeahead, "o inhibit_exit";
}
See perldoc perl5db for more information.
Update:
A simpler approach is to the readline init file. You can use a global file ~/.inputrc
or a use a local one for the current debugging session only by setting the environment variable INPUTRC
. For example, using the above perldb_inputrc
file as an example, you could use (in your .perldb
init file):
sub afterinit { push @DB::typeahead, "o inhibit_exit" }
and then run the Perl script like this:
INPUTRC=./perldb_inputrc perl -d myscript.pl
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |