A week ago I started a little script to format the output of file and path listings from other programs. It got a little bit out of hand and I implemented lot of advanced features into the fmt commands; kind of a sub language to define how the output should be formatted and structured. Entire idea is to give it paths, process the stream (not the file content itself, but the path representing a file) and output them again.
fpath accepts two type of input: a) either as arguments like fpath *.txt
or b) from stdin like ls -1 | fpath
. With additional options and commands the output can be colored and reformatted to something entirely different. In example with -F
option the advanced formatting is possible, such as fpath -F '{.size} {name}'
as a simple example.
There is lot of functionality (based on Python, yes this is a Python script), such as {reverse}{name}{/reverse}
to reverse font color and background of the segment that is enclosed by the command, a slice to get a subset as a range from the entire path {-1:}
, or {center:80}text{/center}
to add spaces to get centered text, or just {ext}
to output the extension, {mime}
to output the file mime type, or even execute arbitrary programs {!grep:a}{path}{/!}
to reduce output that has an a
in the path.
Did I over engineer it again? Or just ignore most stuff and use it with the most simple options, should be enough anyway: fpath -t -s red *.txt
Did you over engineer? Yes! Also: this is very cool!!