diff --git a/README.md b/README.md index 277b641..96c8b36 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1805 TILs and counting..._ +_1806 TILs and counting..._ See some of the other learning resources I work on: @@ -1810,6 +1810,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Print A Range Of Lines For A File With Bat](unix/print-a-range-of-lines-for-a-file-with-bat.md) - [Print DateTime Represented By Unix Timestamp](unix/print-datetime-represented-by-unix-timestamp.md) - [Print Milliseconds In Human-Readable Format](unix/print-milliseconds-in-human-readable-format.md) +- [Print Out File With Bat Without Formatting](unix/print-out-file-with-bat-without-formatting.md) - [Print Out Files In Reverse](unix/print-out-files-in-reverse.md) - [Print The Current Date In Human-Readable Format](unix/print-the-current-date-in-human-readable-format.md) - [Produce A Lowercase V4 UUID](unix/produce-a-lowercase-v4-uuid.md) diff --git a/unix/print-out-file-with-bat-without-formatting.md b/unix/print-out-file-with-bat-without-formatting.md new file mode 100644 index 0000000..0a4f9e5 --- /dev/null +++ b/unix/print-out-file-with-bat-without-formatting.md @@ -0,0 +1,28 @@ +# Print Out File With Bat Without Formatting + +The [`bat`](https://github.com/sharkdp/bat) utility is my daily driver and +replacement for anything used `cat` for before. I even have `bat` aliased to +`cat` so that I never had to rewire my muscle memory for typing `cat`. + +Whether or not the creator of `cat` intended it, I'd guess that most terminal +users' main use case is printing the contents of a file. `bat` does that way +better with syntax highlighting, line numbers, and some layout formatting that +puts lines around the output and a heading with the filename. + +All this formatting is great when I'm taking a quick look at a file. One way it +gets in the way is when I'm trying to highlight and copy a few lines to my +clipboard. Because the terminal is rendering lines, line numbers, and other +formatting, all that fluff gets included on the clipboard. + +For this scenario, I can use the `-p` flag (or `--style=plain`) to print just +the (syntax-highlighted) file contents without all the extra formatting. + +```bash +bat -p app/models/users.rb + +# or +bat --style=plain app/models/users.rb +``` + +Another way I could have approached this was to [ignore the alias of `cat` to +`bat`](ignore-the-alias-when-running-a-command.md).