shellmarkdownstdoutmanpagepbcopy

Is this a pbcopy command garbled bug?


Is this a pbcopy command garbled bug? If so, is there a way to fix it?

I've tried a few ways but still can't found why this is happened.

error / bug

Steps to reproduce

# 1. copy output
$ man grep | pbcopy

# 2. paste to a markdown file

# 3. view the markdown file

enter image description here

using vscode open the markdown file, still garbled

enter image description here

template solutions

  1. output to a markdown file
# stdout
$ man ls > man-ls.md
# $ man grep > man-grep.md

# no pagination problem ✅
$ cat man-ls.md
# $ cat man-grep.md

enter image description here

  1. manually copy & paste (page by page 👎)
# copy man docs, page by page
$ man grep

enter image description here


Solution

  • vscode solution ✅

    use vscode to fix copy from the terminal encoding bug 🚀

    steps

    1. export one .md markdown file
    # export
    $ man shutdown > shutdown.md
    # $ man grep > grep.md
    
    
    1. open exported .md file with vscode

    2. select all " symbols, and press the backspace/back delete key twice (🔙)

    That's all.

    gif demo

    enter image description here