-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
possibility to suppress output if stdin is empty and set header manually #2916
Comments
I think having an extra opt-in command line flag to disable printing the header for binary and/or empty files would be fine. It would be especially useful when using
The For your specific example of finding TODOs in source code files, ripgrep might be a more performant approach compared to rg --vimgrep --with-filename 'TODO' | cut -d':' -f1 | uniq | xargs bat There's also batgrep if you want a bit more of a tailored experience: |
Hi @eth-p , for me, it's just show ALL contents of files contains
using base on your example, following commands resolved rg --vimgrep --with-filename 'TODO' --color never |
cut -d':' -f1 |
uniq |
xargs -r -I{} bash -c "sed -ne '/TODO:/,/^\s*$/p' {} |
bat -l groovy" However, it still didn't show the exact file name... i.e.: here is my batconfig $ cat ~/.config/bat/config | sed -r '/^(#.*)$/d' | sed -r '/^\s*$/d'
--theme="gruvbox-dark"
--style="numbers,changes,header"
--italic-text=always
--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"
--map-syntax "*.ino:C++"
--map-syntax ".ignore:Git Ignore"
--map-syntax='*.conf:INI'
--map-syntax='/etc/apache2/**/*.conf:Apache Conf'
--map-syntax "**/jenkinsfile/**/*:Groovy" more on sed && sed+bat: |
Hi @marslo Your understanding of both of those is correct, yes. For your issue with rg --vimgrep --with-filename 'TODO' --color never |
cut -d':' -f1 |
uniq |
xargs -r -I{} bash -c "sed -ne '/TODO:/,/^\s*$/p' {} |
bat -l groovy --file-name='{}'" |
I'm using
sed
commandline to fetch all ofTODO
in source code and shows viabatcat
as below:However, the
bat
showsSTDIN <EMPTY>
ifsed
command returns nothing.currently I'm using
if..else..
to show content via bat as below:Any better solution to suppress output if stdin is empty, and by the way, it's nice to have a feature to setup header manually if content is from stdin to easier identify where the output comes from
thanks.
The text was updated successfully, but these errors were encountered: