Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chriskrycho/bye

A tiny tool for 'deleting' big directories via $TMPDIR
https://github.com/chriskrycho/bye

Last synced: about 2 hours ago
JSON representation

A tiny tool for 'deleting' big directories via $TMPDIR

Awesome Lists containing this project

README

        

# `bye` :wave:

A trivial tool to get rid of a folder by moving it to `$TMPDIR` instead of deleting it (which is must faster than doing an `rm -rf`) and then letting the OS clean it up later. Adds a little random noise to the names to avoid collisions.

## Setup

1. Install Rust if you don't already have it.

```sh
brew install rustup-init
rustup-init
source $HOME/.cargo/env
rustup update stable
```

2. Clone the repo and build it.

```sh
git clone [email protected]:chriskrycho/bye
cd bye
cargo build --release

3. Put it somewhere on your PATH:

```sh
cp ./target/release/bye
```

Now, you can just run `bye node_modules` and it'll get rid of it more or less instantaneously.

## Why/how

This is mostly useful for dealing with especially large directories with many files (e.g. `node_modules`): `rm -rf` can take a *long* time. This is more or less instantaneous on modern file systems, because it does not perform a copy or a “move”: it just changes where the link on the file system to that directory is.

You can do the same thing with `mv` yourself, of course:

```sh
mv node_modules $TMPDIR
```

For a while that’s what I was doing. However, if you’re cleaning up folders with the same name over time, you can end up with name collisions—so then you need to add some kind of noise for the names. I got tired of that and wrote this.