Skip to content

Repository files navigation

trim-whitespace-rs

A dead simple CLI to remove trailing whitespace from files. Inspired by the UNIX philoshophy and the fact that I somehow keep leaving whitespaces when taking notes in Emacs.

Installation

Assuming you have the Rust toolchain setup, you can compile it from source and install via cargo:

cargo install --locked --git https://github.com/vvzen/trim-whitespace-rs

The installed binary will be called trim.

Soon enough I might set up a CI for it.

Usage

Trim some-file.txt in place:

trim -i some-file.txt

You can also pass multiple files:

trim -i my-file-a.txt my-file-b.txt

Trim data passed to stdin:

echo -n 'hello, world   ' | trim -

For example:

$ echo -e 'hello, world   \nbonjour, globe' | hexdump -c
0000000   h   e   l   l   o   ,       w   o   r   l   d              \n
0000010   b   o   n   j   o   u   r   ,       g   l   o   b   e  \n
000001f

$ echo -e 'hello, world   \nbonjour, globe' | trim - | hexdump -c
0000000   h   e   l   l   o   ,       w   o   r   l   d  \n   b   o   n
0000010   j   o   u   r   ,       g   l   o   b   e  \n
000001c

About

A dead simple CLI to trim trailing whitespace from files. Because I always forget the right sed or awk incantation.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages