You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Terminal copy setting

I have a command-line program that generates some tab-delimited text output that I'd like to paste into an Excel worksheet. I'd like the tabs to define columns. I am using Excel 16.74 on Mac OS Ventura (v13.4.1). I run the program in Mac OS Terminal. I do this on 2 Macs (both running the same software versions), A 13" M1 MacBook Air and a Mac Studio. On one the Studio, the paste works as desired. On the Air, it works if I go to paste special and select Text instead of the default, HTML. It would be nice if I could do it on both Macs using cmd-V instead of having to use paste special and then select Text.

 

The Show Clipboard Contents in finder indicates that the clipboard has rich text on the Air (where pasting doesn't work as desired) and as text on the Studio (where it does work). I don't see any relevant settings in Terminal preferences. Any suggestions how to set the terminal to recognize copied text as simple text rather than rich text?


MacBook Air 13″, macOS 13.4

Posted on Jul 3, 2023 7:35 AM

Reply
8 replies

Jul 3, 2023 11:39 AM in response to ef_in_md

There are only two ways to get a propery formatted CSV or TSV into Microsoft Excel 16.74 and neither involve the clipboard, right-clicking the CSV in Finder and choosing Open With, or piping the script output into Excel. Do either of the following:


  1. Excel File menu : Import and select CSV, then click import and follow the remaining steps.
  2. Excel Data menu : Get External Data : Import Text File : and follow the remaining interactive instructions.


Tested: macOS 13.4.1 and Excel 16.74.

Jul 3, 2023 9:56 AM in response to ef_in_md

I recommend you use the "pbcopy" command in the Terminal. Just run your command line tool as normal. But instead of letting the output display in the terminal, pipe it to pbcopy, like this:


/path/to/my/script --some_option1 --some_option-2 | pbcopy


This will copy the text of the output to the clipboard and should do it the same on both computers. From there, you can paste into Excel.

Jul 3, 2023 4:37 PM in response to ef_in_md

ef_in_md wrote:

Thanks. I only need a few line of the output. I could cook up a script to show only the needed lines and then pbcopy would. However, it is weird that it works on one Mac and not the other (because of the format in the clipboard).

Maybe check to see how your Terminal is configured. The default is xterm256-color. When I copy color text from Terminal and paste it into Excel, it works just as well as any other text. When I do the text to columns command, it removes all the formatting.

Terminal copy setting

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.