A tiny Python script that unwraps soft line breaks from terminal output into clean paragraphs — useful for pasting Claude Code / ChatGPT / other wrapped terminal output into Slack, email, docs, etc. without the ugly mid-sentence line breaks.
- Reads from stdin (or a file path argument)
- Joins hard-wrapped lines back into paragraphs
- Preserves blank lines, bullet lists, and box-drawing table rows
- Zero dependencies — just Python 3
Requires Python 3 (already on macOS and most Linux distros).
Clone the repo and copy the script onto your PATH:
git clone https://github.com/ericgjerde/unwrap.git
cd unwrap
install -m 755 unwrap ~/.local/bin/unwrapMake sure ~/.local/bin is on your PATH. If it isn't, add this to your
~/.zshrc or ~/.bashrc:
export PATH="$HOME/.local/bin:$PATH"git clone https://github.com/ericgjerde/unwrap.git
cd unwrap
make install # installs to ~/.local/bin
# or
sudo make install PREFIX=/usr/local # system-wideUninstall with make uninstall (uses the same PREFIX).
# from stdin
echo "some wrapped
text with soft
line breaks" | unwrap
# from a file
unwrap notes.txtThe reason this exists. Add to your ~/.zshrc:
alias qwe='pbpaste | unwrap | pbcopy'Now copy messy wrapped text, run qwe, and paste clean paragraphs.
With xclip:
alias qwe='xclip -selection clipboard -o | unwrap | xclip -selection clipboard'Or with wl-clipboard (Wayland):
alias qwe='wl-paste | unwrap | wl-copy'- Blank lines separate paragraphs and are preserved.
- Lines containing box-drawing characters (
│├┌└─etc.) are kept verbatim so tables don't get smooshed. - Lines starting with
-start a new bullet. - Everything else gets joined with a single space.
MIT — see LICENSE.