question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: see N context lines around matches

See original GitHub issue

I recently missed a couple of times the -A/B/C argument of grep (but then for “bh”): finding lines around my target command (when I don’t remember some new command but I do remember ssh was called before).

A: n lines before match B: n lines after match C: n lines before and after match

Example: grep -r -C 5 “test” .

--
--
./new.py-
./new.py-from sqlalchemy import create_engine, MetaData, Table, Column
./new.py-from sqlalchemy import Integer, Unicode, UnicodeText
./new.py-from sqlalchemy import ForeignKey
./new.py-
./new.py:engine = create_engine("postgresql://postgres@localhost/test")
./new.py-
./new.py-metadata = MetaData()
./new.py-
./new.py-countries_table = Table("countries", metadata,
./new.py-                        Column("id", Integer, primary_key=True),

Notice the line with “test” and 5 lines before and after. It uses – two times to delimit multiple matches. I’m indeed missing colors on the “test” match, I had to specifically add --color=always|auto flag. It would be nice to be the default to use colors I guess.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kootenpvcommented, Nov 9, 2017

Wow, this has been a long time. I still find myself wanting this very much: just a little peek around a selected command. The better implementation would probably to use it as an extra option in interactive? After you’ve selected a command, enter a second selection of the commands around this. It’s very crucial, as sometimes you want to know for example to which directory you’ve moved or something before executing a command, or know what other steps you took.

Thanks my friend, still an active user of bashhub every day 😃

0reactions
kootenpvcommented, Mar 17, 2021

@DanEdens and @rcaloras thanks a lot, it’s great to know next time I can easily then filter on timestamp/session!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keep selection after `clear-query` (to see original context of ...
Problem / Steps to reproduce ... Use Case: a) filter ('search') a list by entering a query; b) have matches; c) then I...
Read more >
[Feature Request] Show only differences (with context) - GitLab
When comparing large files with a few differences, it would be very useful to hide matching lines and show only the lines that...
Read more >
Visual Studio Code - Include context in search results
View lines of context surrounding a result. Persist results to disk to be referenced later or even tracked in SCM. We will be...
Read more >
Show context around old Teams messages from search results
When I search for a certain keyword - say, "hot dog" - I get results that are both old and recent from past...
Read more >
when clause contexts | Visual Studio Code Extension API
when clause contexts. Visual Studio Code sets various context keys and specific values depending on what elements are visible and active in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found