sqlplus: Running "set lines" and "set pagesize" automatially
Posted
by katsumii
on Oracle Blogs
See other posts from Oracle Blogs
or by katsumii
Published on Thu, 27 Sep 2012 17:48:48 +0000
Indexed on
2012/09/27
21:45 UTC
Read the original article
Hit count: 288
/Misc
Using the full tty real estate with sqlplus (INOUE Katsumi @ Tokyo)
'rlwrap' is widely used for adding 'sqlplus' the history function and command line editing.Here's another but again kludgy implementation. First this is the alias.
alias sqlplus="rlwrap -z ~/sqlplus.filter sqlplus"
And this is the file content.
#!/usr/bin/env perl use lib ($ENV{RLWRAP_FILTERDIR} or "."); use RlwrapFilter; use POSIX qw(:signal_h); use strict; my $filter = new RlwrapFilter; $filter -> prompt_handler(\&prompt); sigprocmask(SIG_UNBLOCK, POSIX::SigSet->new(28)); $SIG{WINCH} = 'winchHandler'; $filter -> run; sub winchHandler { $filter -> input_handler(\&input); sigprocmask(SIG_UNBLOCK, POSIX::SigSet->new(28)); $SIG{WINCH} = 'winchHandler'; $filter -> run; } sub input { $filter -> input_handler(undef); return `resize |sed -n "1s/COLUMNS=/set linesize /p;2s/LINES=/set pagesize /p"` . $_; } sub prompt { if ($_ =~ "SQL> ") { $filter -> input_handler(\&input); $filter -> prompt_handler(undef); } return $_; }
I hope I can compare these 2 implementations after testing more and getting some feedbacks.
© Oracle Blogs or respective owner