fd, xargs, bat = quick document review
hiandrewquinn.github.io
hiandrewquinn.github.io
fd '.fi.md$':
fd is a program similar to the traditional find command but with a more user-friendly syntax and faster performance. '.fi.md$' is a regular expression. It matches files whose names end with .fi.md. The dollar sign $ in regular expressions signifies the end of a line or string, so this ensures that the command only finds files that exactly end with .fi.md. |:
This is a pipe. It takes the output of the command on its left (the list of files found by fd) and uses it as the input for the command on its right. xargs -I _ -- batcat --paging=always _:
xargs is a command used to build and execute command lines from standard input. -I _ tells xargs to replace occurrences of _ in the initial arguments with names read from standard input (the list of files provided by fd). -- is used to signify the end of command options, after which only positional arguments are accepted. batcat --paging=always _: Here, batcat is likely an alias or a symlink to bat, a command that provides syntax highlighting and Git integration for a variety of file types, and it's an improved version of the cat command. --paging=always ensures that bat always uses a pager (like less) to display the file content, regardless of the size of the file. _ is replaced by each file name from the output of fd. Putting it all together:
The command finds all files ending in .fi.md in the current directory and subdirectories. For each of these files, it then calls batcat (or bat) with the --paging=always option, effectively displaying their contents with syntax highlighting and paging, allowing you to scroll through the content if it's longer than the screen size.
Everything after the first sentence in this comment seems to be LLM generated.
>oneliners like these
It is literally one pipe. You can't really get simpler than this.
ls
But thanks for taking the time to explain.
That's not what I'm after. I want to survey the whole page with my eyes as fast as possible for unusual colors / oddly short files / etc, then press `q` to have the screen totally clear and move on to the next one.
The default (/usr/bin/lesspipe.sh, shipped with less) isn't very clever. It can uncompress files in some common formats and open images, but isn't very smart and doesn't handle markdown or code of any kind as far as I can tell.
export FZF_CTRL_T_OPTS="--preview='less {}' --height=100% --bind shift-up:preview-page-up,shift-down:preview-page-down"
This lets you hit CTRL+t and immediately start previewing files in a directory with an ability to page between results.A video walk through and demo of that is here: https://nickjanetakis.com/blog/customize-fzf-ctrl-t-binding-...
You can reference FZF's env variable to reduce duplication too:
alias pf="fzf ${FZF_CTRL_T_OPTS}"