Closed audunsol closed 2 years ago
After reading a bit further, and visiting https://pygments.org/docs/lexers/#pygments.lexers.configs.DockerLexer I now realized how the --lexer
option works, and that it 100% solves my problem (and all similar problems with other file types in the same go) 🤦♂️
For completeness, the modified versions of the commands above, that does what I want is:
# Named something else than just Dockerfile:
rich --lexer=docker Dockerfile.service1
# When used as "file extension":
rich --lexer=docker service1.Dockerfile
# But if using the file extension `docker`, as described in https://pygments.org/docs/lexers/#pygments.lexers.configs.DockerLexer, it will be recognized, and I can avoid that option:
mv service1.Dockerfile service1.docker
rich service1.docker
# When coming from stdin:
cat Dockerfile | rich - --lexer=docker
# The other stdin example, using short-alias for variation:
cat Dockerfile | sed 's/FROM \S*/FROM node:16/gi' | rich - -x docker
Closing this now. So sorry about the noise!
Thanks again for a great tool - it just became even better for me after understanding how to use this option!
Dockerfiles are nicely formatted when running
rich Dockerfile
. Thanks! :+1:But when the dockerfile is named something else, or when its ouput comes from stdin, it seems to not be possible to request Dockerfile rendering, as there is no
--dockerfile
flag (similar to how it works for--markdown
).What is currently working (i.e. gives nice color coded output):
What is currently not working (renders the file just like
cat
):