withd
withd is a simple command-line tool that allows you to run a command with a
different working directory without affecting the current shell's working
directory.
Why is this useful?
Many commands – such as git, npm, and cargo – require you to run them from
a specific directory. This can be done by cding into the directory:
or by using a subshell to isolate the change:
( && )
The first is cumbersome. The latter can be confusing when also trying to work with shell variables in a script, for example, since the subshell cannot propagate changes to the parent shell. It's also easy to forget.
Then there's CDPATH. If this is set in your shell, cd's behaviour changes
and you might end up in a different directory than you expected. I've seen this
be a source of confusion – and a disruptive and very difficult to diagnose bug.
withd does not have these problems. It's simple and predictable.
Installation
For now, use Cargo:
Usage
To create the directory:
(-c is short for --create.)
Making a release
- Bump version in
Cargo.toml. - Build and test. The latter on its own does do a build, but a test build
can hide warnings about dead code, so do both.
- With default features:
cargo build && cargo test - Without:
cargo build --no-default-features && cargo test --no-default-features
- With default features:
- Commit with message "Bump version to
$VERSION." - Tag with "v
$VERSION", e.g.git tag v1.0.10. - Push:
git push && git push --tags. - Publish:
cargo publish.
License
GNU General Public License 3.0 (or later). See LICENSE.