Luce Carter Logo

  • Productivity
  • Terminal
  • CLI
  • Mac
  • Windows

How to copy and paste in the CLI for both Mac and Windows

I recently received an email from someone, asking me how to copy and paste into the command-line interface (CLI) because they were trying to add some credentials for the Twilio CLI.

I realised that it isn't actually that obvious, as the traditional shortcuts we are used to (ctrl/cmd + c/v) don't always work depending on the operating system and CLI shell you are using. It prompted me to create this Youtube video showing how to do it. However we all consume content in different ways, so I thought I would also write this post for you in case you prefer written instructions.

Windows

I will start with Windows as this can be the most counter-intuitive. I have tested this in both Command Prompt and Powershell, which are the two most common CLI tools that you get out of the box with Windows.

Copy

This can be done as you would expect, with ctrl + c or using the mouse to select what you wish to copy from CLI and using right-click. Instead of bringing up a context menu, this simply copies whatever you have highlighted.

Paste

For some, the traditional ctrl + v will work, however your experience may vary. If pasting with ctrl + v isn't working for you, a simple right-click will actually paste what is currently on your clipboard!

Mac

I tested this on both the default Terminal and the choice of many of us, iTerm 2 and the results were the same. On Mac things are as you would expect.

Copy

This is as you would expect, cmd + c will copy whatever is selected. You can also right-click the highlighted text and click copy.

Paste

Just like with copy, this is the usual cmd + v to paste and you can also do right-click and paste. Easy!!

Summary

So there you have it, a quick written guide on how to copy and paste in CLI on both Mac and Windows. I hope you have found this helpful!

You can of course tweet me if you have any questions or wish to see another topic coverd as a video and/or blog post. Thanks for reading! :)

Luce Carter

Dev 🥑 at MongoDB | Microsoft MVP | Twilio Champion | I help developers build confidence and battle Impostor Syndrome, one line of code or story at a time | She/Her