How do I capture bash output to the Mac OS X clipboard?

前端 未结 3 1748
忘掉有多难
忘掉有多难 2021-01-29 19:16

Is it possible to capture bash output to the OS X clipboard?

相关标签:
3条回答
  • 2021-01-29 19:45

    In case you want to capture error messages, this will work:

    cmd 2>&1  | pbcopy
    
    0 讨论(0)
  • 2021-01-29 19:57

    You can do this using the pbcopy command:

    pbcopy < ./path/to/file/or/output/stream
    
    0 讨论(0)
  • 2021-01-29 20:08

    The pbcopy command does this.

    For example, this puts the output from ls on the clipboard/pasteboard:

    ls | pbcopy
    

    And pbpaste does the reverse, writing to stdout from the clipboard:

    pbpaste > ls.txt
    

    You can use both together to filter content on the clipboard - here's a rot13:

    pbpaste | tr 'a-zA-Z' 'n-za-mN-ZA-M' | pbcopy
    
    0 讨论(0)
提交回复
热议问题