DEV Community

Avinash Sivaraman
Avinash Sivaraman

Posted on

6 4

⚑️ Lighting blaze file content copying to the Clipboard (Mac) πŸ’»

Have you ever tried to copy the content of a file and paste it somewhere else like copying a JSON file and pasting it in some website. When you want to copy a file, we need to open a file and select all the content by command + A (or using the mouse) and copying the content of the file.

Here is the trick to copy the content directly from the terminal.

pbcopy < filename.txt

We can simplify the command by adding an alias in our .bashrc file. So, we don't need to type this whole command to copy the content. Open the .bashrc in vim or any other editor of your choice.

 vim ~/.bashrc

Add the below line inside the .bashrc file and save it.

alias cc='pbcopy <'

Now we need to restart the terminal or run the below command in the terminal to see our alias in action.

source ~/.bashrc

Finally, you can copy the content of the file by using the cc command and this command is local to your machine.

cc demo.txt

Happy Coding πŸ’». You can find my personal .bashrc file which contains a lot of GitHub and npm shortcuts here. I am really happy to discuss more tips and tricks to improve productivity. Feel free to comment down below ⬇️

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
karthikgk97 profile image
Karthik Ganesan β€’

Very helpful blog.

Collapse
 
jjdharshini4 profile image
Dharshini Jaiganesh β€’

It's an useful and an easy read! πŸ‘πŸ‘

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post