Record your shell session and replay it as a clean, shareable bash script.
trapsh acts as a transparent background recorder for your terminal. It hooks into your fish (or bash/zsh or powershell) session, records the commands you run, filters out the noise (like failed commands, typos, and syntax errors), and outputs a clean, ready-to-use bash script.
Perfect for creating tutorials, sharing reproduction steps, or just automating your workflow without having to write the script from scratch.
- Noise Filtering: Automatically removes failed commands, duplicate entries, and typos from the final output.
- Cross-Shell Support: Hook installation is supported for
fish,bash,zsh, andpowershell. - Clean Output: Generates a standardized bash script (
trapsh_out.sh) that you can immediately run or share. - Live Preview: See what your final script will look like before you stop recording.
You can download the pre-compiled, standalone binaries from the Releases page for Linux, macOS, and Windows. You do not need Rust installed to run these.
Linux & macOS:
- Download the
trapsh-linux-amd64ortrapsh-macos-*binary. - Make it executable and move it to your PATH:
chmod +x trapsh-* sudo mv trapsh-* /usr/local/bin/trapsh
Windows:
- Download the
trapsh-windows-amd64.exebinary. - Rename it to
trapsh.exe. - Add the folder containing
trapsh.exeto your system'sPATHenvironment variable.
Ensure you have Rust and Cargo installed, then run:
# Build and install from source
cargo install --path .
# Install the shell hooks (supports fish, bash, zsh, powershell)
trapsh install if you get the error trapsh: command not found , then run this:
#if your shell is bash
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
#if your shell is zsh
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
#if your shell is fish
fish_add_path ~/.cargo/bin
#if your shell is powershell
Add-Content $PROFILE "`n`$env:PATH = `"`$env:USERPROFILE\.cargo\bin;`$env:PATH`""Using trapsh is simple. Start a session, do your work, and stop it when you're done.
# 1. Begin recording your session
trapsh start
# 2. ... Run your commands normally ...
$ mkdir my_project
$ cd my_project
$ npm init -y
# 3. Check the status of your current session
trapsh status
# 4. Preview the generated script so far
trapsh show # Filtered, clean preview
trapsh show --raw # Show everything, including noise and failed commands
# 5. Stop recording and save the output
trapsh stop # Saves to ./trapsh_out.sh
trapsh stop -o setup.sh # Saves to a custom file
trapsh stop --raw # Save the unfiltered sessionWhen you run trapsh start, it initializes a tracker that logs your shell history in real-time. Upon running trapsh stop, it analyzes the return codes of your executed commands, strips out anything that failed (unless --raw is passed), and writes the successful sequence to a file.
Contributions, issues, and feature requests are welcome! Feel free to open an issue or pull request.