Quickly copy path to clipboard
Marcell Cruz
Posted on September 3, 2020
It's very common to have a terminal window opened in a specific folder, and then you realize that you need to do something else in that same folder, then you open a new terminal window and have to navigate to the folder that you were in the previous window, it's happens a lot and it's annoying.
There's a quick and easy way to solve this problem that works in any platform, terminal emulator etc..
Just create a script called pwdc place the following code
#!/usr/bin/bash
pwd | xclip -selection clipboard
What this script does is to copy your current directory to your clipboard
pwd means (print working directory), that's why the name of the script is pwdc, the c stands for copy, but of course, you can name the script whatever you want, after creating the script you need to make it executable
chmod +x ./pwdc
and you also need to install xclip if you don't already have, after that you need to move the script to your path, so you can call it anywhere, and that's it, now you can easily copy you current directory open a new terminal window and navigate to it
Posted on September 3, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.