Created
November 14, 2019 22:00
-
-
Save nugend/c84ab9e7478023c4ac375488b6654b3c to your computer and use it in GitHub Desktop.
RLWrap Strip Newlines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias q='rlwrap --multi-line --multi-line-ext=.q --filter=/path/to/remove_newline.pl --no-warnings q' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# filter to remove newlines from an editor session (initiated with Ctrl-^) | |
use lib ($ENV{RLWRAP_FILTERDIR} or "."); | |
use RlwrapFilter; | |
use strict; | |
my $filter = new RlwrapFilter; | |
my $name = $filter -> name; | |
$filter -> help_text("Usage: rlwrap --multi-line --filter='$name' --no-warnings\n". | |
"Removes newlines from editor session text\n" | |
); | |
$filter -> input_handler(\&scrub); | |
$filter -> run; | |
sub scrub { | |
my ($dirty) = @_; | |
my $clean = $dirty; | |
$clean =~ s/^$/;/gm; | |
$clean =~ s/^\s+//gm; | |
$clean =~ s/\n//g; | |
return $clean; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the
Ctrl+^
key in the interpreter to drop into the editorBorrowed from... somewhere. I don't remember where.