From f908fad4dddf419c5731d84cda1521b5a1191b98 Mon Sep 17 00:00:00 2001 From: John Sebastian Peterson Date: Wed, 4 Jun 2025 17:34:59 +0300 Subject: [PATCH] add B<--nolinenumber> I use --pager="vim - -R" and my whole work flow revolves around copying and moving lines and blocks. hence littering makes no sense I need clean lines plus I use touch input so minute fiddling is a night mare --- ack | 12 ++++++++++++ lib/App/Ack/ConfigLoader.pm | 1 + 2 files changed, 13 insertions(+) diff --git a/ack b/ack index 9ab33623..3b84b004 100755 --- a/ack +++ b/ack @@ -50,6 +50,7 @@ our $opt_regex; our $opt_show_filename; our $opt_show_types; our $opt_underline; +our $opt_nolinenumber; our $opt_v; # Flag if we need any context tracking. @@ -158,6 +159,7 @@ MAIN: { $opt_show_filename = $opt->{show_filename}; $opt_show_types = $opt->{show_types}; $opt_underline = $opt->{underline}; + $opt_nolinenumber = $opt->{nolinenumber}; $opt_v = $opt->{v}; if ( $opt_show_types && not( $opt_f || $opt_g ) ) { @@ -915,6 +917,11 @@ sub print_line_with_options { $disp_lineno = $lineno; } + if ( $opt_nolinenumber ) { + $disp_lineno = ""; + $separator=""; + } + if ( $opt_heading ) { push @line_parts, $disp_lineno; } @@ -922,6 +929,7 @@ sub print_line_with_options { push @line_parts, $disp_filename, $disp_lineno; } + if ( $opt_column ) { my $colno = get_match_colno(); $colno = Term::ANSIColor::colored( $colno, $ENV{ACK_COLOR_COLNO} ) if $opt_color; @@ -1813,6 +1821,10 @@ also L. The filters associated with TYPE are removed from Ack, and are no longer considered for searches. +=item B<--nolinenumber> + +disable line number + =item B<--[no]underline> Turns on underlining of matches, where "underlining" is printing a line of diff --git a/lib/App/Ack/ConfigLoader.pm b/lib/App/Ack/ConfigLoader.pm index 4c198cbf..92d146d0 100644 --- a/lib/App/Ack/ConfigLoader.pm +++ b/lib/App/Ack/ConfigLoader.pm @@ -353,6 +353,7 @@ sub get_arg_spec { 't|type=s' => \&_type_handler, 'T=s' => sub { my ($getopt,$value) = @_; $value="no$value"; _type_handler($getopt,$value); }, 'underline!' => \$opt->{underline}, + 'nolinenumber!' => \$opt->{nolinenumber}, 'v|invert-match' => \$opt->{v}, 'w|word-regexp' => \$opt->{w}, 'x' => sub { $opt->{files_from} = '-' },