- ...
- select mode (optional, URL mode is used on startup):
- f: file paths
+ - i: IPs
- u: URLs
- ...
- /: search mode
# Draw matches in blue.
$config{attribute}{match_string} = color_pair(COLOR_BLUE, -1);
- # Enable Vim-like 'smartcase', ignore case until an upper character is
+ # Draw numbers in bold yellow.
+ $config{attribute}{match_id} = color_pair(COLOR_YELLOW, -1)
+ | A_BOLD;
+ # Disable Vim-like 'smartcase', ignore case until an upper character is
# searched.
- $config{setting}{smartcase} = 1;
+ $config{setting}{smartcase} = 0;
# Use chromium to open URLs if running under X, elinks otherwise.
if (defined $ENV{DISPLAY}) {
$config{setting}{browser} = ['chromium'];
} else {
- $config{setting}{browser} = ['elinks'];
+ $config{setting}{browser} = ['elinks', '-remote'];
}
# Let fcscs know the file was loaded successfully.
I<NOTE>: Mappings are split in two categories: Mode mappings which change the
selection and may receive additional input (e.g. a search string) and simple
-mappings which only change some value. Mode mappings are configured via
+mappings which only change some config value. Mode mappings are configured via
C<$config{mapping}{mode}>, simple mappings via C<$config{mapping}{simple}>.
The following mode mappings are available by default (the function to remap
Used as handler to yank, paste selection or open URL in browser.
- debug()
get_regex_matches()
select_match()
run_command()
Example:
- TODO
+ # Enhance URL mode by updating the mapping.
+ $config{mapping}{mode}{u} = sub {
+ my ($key, $screen, $config, $input) = @_;
+
+ # First get matches of normal URL mode.
+ my $result = mapping_mode_url(@_);
+
+ # Add all strings matching "CVE-1234-1234" with URLs pointing to the
+ # Debian security tracker. "->{value}" is the string which is used as
+ # result of the match (e.g. the URL in this case).
+ my @matches = get_regex_matches($input, qr/\b(CVE-\d+-\d+)\b/);
+ foreach (@matches) {
+ $_->{value} = "https://security-tracker.debian.org/$_->{string}";
+ }
+ push @{$result->{matches}}, @matches;
+
+ # Change all YouTube links to use the custom "youtube" handler (see
+ # below). This will allow us to automatically open YouTube URLs with a
+ # custom program, like `youtube-dl` or `mpv`.
+ foreach (@{$result->{matches}}) {
+ if ($_->{string} =~ m{^https://www.youtube.com/}) {
+ $_->{handler} = $config{handler}{youtube};
+ }
+ }
+
+ return $result;
+ }
+ # Also update initial mode to use our new "URL mode".
+ $config{setting}{initial_mode} = $config{mapping}{mode}{u};
+
+ # Special handler to download YouTube URLs with `youtube-dl`. You could
+ # also use `mpv` here to immediately play them.
+ $config{handler}{youtube} = sub {
+ my ($screen, $config, $match) = @_;
+
+ return run_in_background($screen, sub {
+ run_command($screen, ['youtube-dl', $match->{value}]);
+ });
+ };
+
+
=cut