1
0
Fork
You've already forked ruz
0
prompt (y/N) for potentially destructive shell commands
  • Rust 100%
2026年02月10日 11:35:32 +01:00
src sudo now working, removed ctr, added docs for it 2026年02月10日 10:01:26 +01:00
.gitignore first commit 2026年02月09日 16:35:32 +01:00
Cargo.lock first commit 2026年02月09日 16:35:32 +01:00
Cargo.toml first commit 2026年02月09日 16:35:32 +01:00
LICENSE add LICENSE (GPLv3) 2026年02月10日 10:32:40 +01:00
README.md Update README.md 2026年02月10日 11:35:32 +01:00

ruz

ruz as in R U Zure (Are you sure?) is designed to prompt (y/N) for potentially destructive shell commands and optionally dry run them in a container

installation

  1. download or build the executable: you can download the rust binary ruz from this repository, or download the source and build it (this requires rust):
$ cargo build --release
  1. add to PATH: ensure the binary is added to your system PATH, e.g., by moving the binary to a directory in your path:
$ mv ./ruz /usr/local/bin

usage

usage: ruz [--dry-run] [--dry-run-in-container <runtime[:image]>] [--auto-remove] <command> [args...]

ruz is used by preceeding the commands you find potentially destructive such as:

$ ruz rm -fr /foo

in which you will be prompted:

$ ruz rm -fr /foo
Do you want to execute the command 'rm -fr /foo' @ 'hostname' (y/N)?
Command 'rm -fr /foo' was not executed.

upon first run, ruz will create a configuration file at the following path containing default prompt colour (red):

~/.config/ruz/config.toml

to integrate ruz into your shell, add aliases in your shell's startup file (e.g., .bashrc or .zshrc):

# sudo expansion fix
alias sudo='sudo '
# aliases you want to put in the safety net
alias rm='ruz rm'
alias zfs='ruz zfs'
alias zpool='ruz zpool'

It is important to add sudo alias for this to expand to sudo. The trailing space tells your shell to also expand aliases on the word following sudo. So sudo rm -fr /foo will expand rm to ruz rm, giving you sudo ruz rm -fr /foo.

examples

brief examples of commands in which ruz can be useful:

  • removing files and directories:

    $ ruz rm -fr /foo
    
  • destroy zfs datasets:

    $ ruz zfs destroy foo
    
  • destroy zpools:

    $ ruz zpool destroy foo
    

dry-run

  • --dry-run: this option only prints the command that would have been executed, without running it.

  • --dry-run-in-container <runtime[:image]>: this option runs the command within a specified container. This is especially useful if you have setup up an image with a similar setup as the instance you are working on, so you can run the command there beforehand.

examples of specifying container

  • --dry-run-in-container docker:ubuntu:24.04
  • --dry-run-in-container podman:alpine:3.19

requirements

you need to have sudo privileges to run commands in containers. Make sure your user has access to the daemon of your container runtime by adding your user to e.g., the docker or incus group

default Images

if the image is omitted, ruz uses ubuntu24.04 as a default image`.

supported container runtime commands

  • docker
  • podman
  • nerdctl
  • incus

when running commands in a container using ruz, the following parameters are applied:

  • --rm: automatically removes the container when it exits if --auto-remove are parsed
  • mounts the current working directory read-only at /work
  • sets the working directory to /work inside the container

contributing

this source code can be considered experimental and bugs are expected. Please feel free to contribute to make it better.