Simple version control for your shell, letting you undo and redo hundreds of common commands in Zsh, Bash, and Fish. Backs up deleted or overwritten files (rm, cp, touch) using SHA-256 hashing, and also checks for conflicts in paths, inodes, mtimes, etc. Shell execution hooks take <5 milliseconds.
- Download the archive for your platform from GitHub Releases.
- Extract the archive.
- Move the
undoandundo-recordexecutables into a directory in your$PATH(e.g.,/usr/local/bin). - Initialize the hooks by adding a line to your shell configuration file:
- Zsh (
~/.zshrc):eval "$(undo --shell-init zsh)"
- Bash (
~/.bashrc):eval "$(undo --shell-init bash)"
- Fish (
~/.config/fish/config.fish):undo --shell-init fish | source
- Make sure you have the Rust toolchain installed. Clone the repository and run:
cargo build --release
- Add the compiled binaries directory to your
PATH(or copyundoandundo-recordfromtarget/release/to a folder in your$PATH):export PATH="/path/to/undo/target/release:$PATH"
- Initialize the hooks like in step 4 above, or source directly from the repository:
- Zsh:
source /path/to/undo/shell/undo.zsh - Bash:
source /path/to/undo/shell/undo.bash - Fish:
source /path/to/undo/shell/undo.fish
- Zsh:
undo Undo the last executed command
redo Redo the last undone command
undo what Show details about the latest transaction
undo list List the last 20 reversible transactions
undo <UUID> Undo a specific transaction in history
undo help Show the help menu
You can change the settings in ~/.undo/config.json:
{
"max_file_size_mb": 50, // Larger files are skipped during backups
"max_history_count": 1000,
"max_history_age_days": 30,
"max_store_size_gb": 5, // FIFO caps the size of the backup directory
"silent_undo_redo": true, // Undo and redo run completely silently
"silent_rm": true, // Keeps file backups silent during file deletions
"safe_mode": false // Confirmation message when undoing/redoing
}This tool was designed for and explicitly tested on ~110 commands (see below). However, for other commands, there's an automatic fallback mechanism that "state diffs" the working directory's before and after. For small workspaces (<100 files, <50MB), even this fallback has a 100% safety rate and >95% success rate. It extends to hundreds, possibly thousands of commands.
List of explicitly supported commands:
black |
git (add, mv, rm, commit, stash, branch, tag, pull, init) |
rustup (toolchain install, default) |
brew (install, uninstall, remove, rm) |
go (get, mod) |
sed |
bunzip2 |
gunzip |
sqlite3 |
bzip2 |
gzip |
tar |
cargo (add, rm, remove, new, init, build) |
ln |
tee |
chgrp |
mkdir |
touch |
chmod |
mv |
trash |
chown |
nano |
trash-put |
clang |
neovim |
truncate |
clang++ |
npm (install, i, uninstall, remove, rm, un, link, unlink, init, run build) |
unzip |
composer (require, remove, install, update) |
patch |
unxz |
cp |
pip / pip3 (install, uninstall) |
vi |
curl |
pnpm (add, remove, rm, install, uninstall, link, unlink) |
vim |
django-admin (startproject) |
poetry (add, remove, install, update) |
virtualenv |
docker (run, network create, volume create) |
prettier |
wget |
emacs |
python (-m venv) |
xz |
g++ |
python3 (-m venv) |
yarn (add, remove, install, uninstall, link, unlink, build) |
gcc |
rm |
zip |
gem (install, uninstall) |
rmdir |
