DEV Community

Cover image for CPWD and copy the path to clipboard! (For Mac Users)
Preveen Raj
Preveen Raj

Posted on

CPWD and copy the path to clipboard! (For Mac Users)

When I found that the instances of me copying the path of the current working directory has become huge, I wanted to make it a seamless task. There, I found the power of zsh.

Just few step and you are good to go.

  1. Open the .zshrc file in your terminal with the below command:
open ~/.zshrc
Enter fullscreen mode Exit fullscreen mode
  1. Add this line to the end of the file:
alias cpwd="pwd|pbcopy"
Enter fullscreen mode Exit fullscreen mode
  1. Save and Close the file.
  2. You can close your terminal and open a new terminal to see the new changes.
  3. Now, if you just enter cpwd you can copy the current path of the directory you are in to your clipboard.
  4. Go ahead and paste in anywhere you want.

Glad that helped! See ya in another hack!

Top comments (0)