Skip to content

ericgjerde/unwrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unwrap

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

Install

Requires Python 3 (already on macOS and most Linux distros).

Option 1: Manual (recommended)

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/unwrap

Make sure ~/.local/bin is on your PATH. If it isn't, add this to your ~/.zshrc or ~/.bashrc:

export PATH="$HOME/.local/bin:$PATH"

Option 2: Makefile

git clone https://github.com/ericgjerde/unwrap.git
cd unwrap
make install              # installs to ~/.local/bin
# or
sudo make install PREFIX=/usr/local   # system-wide

Uninstall with make uninstall (uses the same PREFIX).

Usage

# from stdin
echo "some wrapped
text with soft
line breaks" | unwrap

# from a file
unwrap notes.txt

macOS clipboard alias

The reason this exists. Add to your ~/.zshrc:

alias qwe='pbpaste | unwrap | pbcopy'

Now copy messy wrapped text, run qwe, and paste clean paragraphs.

Linux clipboard alias

With xclip:

alias qwe='xclip -selection clipboard -o | unwrap | xclip -selection clipboard'

Or with wl-clipboard (Wayland):

alias qwe='wl-paste | unwrap | wl-copy'

How it works

  • 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.

License

MIT — see LICENSE.

About

Unwrap soft line breaks from terminal output into clean paragraphs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors