Note: This document describes Unix-like systems, but similar approaches can be applied to Windows as well. Pull requests adding recipes for Windows are welcome.
To use cargo auditable in place of cargo only when you call it yourself from the sell, use a shell alias:
alias cargo="cargo auditable"When entered into the shell, it will only persist for the duration of the session. To make the change permanent, add it to your shell's configuration file (.bashrc for bash, .zshrc for zsh, .config/fish/config.fish for fish).
When calling other programs such as cmake or maturin, the shell alias usually isn't honored. In this case you can use a different approach:
- Run
which cargoto locate the Cargo binary - Copy the snippet provided below and replace '/path/to/cargo' with the path you got at step 1
- Save it to a file named
cargo - Run
chmod +x cargoto make the script executable - Prepend the path to the directory where you saved the script to your
PATHenvironment variable. For example, if you saved the script as$HOME/.bin/cargo, you need to add$HOME/.bin/to yourPATH. The exact way to do this varies depending on the shell; in bash it'sexport PATH="$HOME/.bin/:$PATH"
#!/bin/sh
REAL_CARGO='/path/to/real/cargo' # replace this with your path
exec "$REAL_CARGO" auditable "$@"