Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy current location to clipboard

Tags:

powershell

How do I copy the current working directory to clipboard?

PS C:\jacek> pwd | CLIP

I get content like below. How can I copy only location/value without any whitespace or description?

Path
--
C:\jacek
like image 963
Jacek Avatar asked Apr 26 '17 11:04

Jacek


People also ask

How do I copy a file path to the clipboard?

Find the file or folder whose path you'd like to copy in File Explorer. Hold down Shift on your keyboard and right-click on it. In the context menu that pops up, select “Copy As Path.”

How do I copy the current URL?

href . window. location. href has the URL of the current page, so the URL will be copied to the clipboard with the copy button is clicked.

What does copy path to Clipboard mean in Excel?

Copy path or Copy as path will copy the full path of selected items (files and folders) wrapped in quotes to the Clipboard so you can paste the full path(s) of the item(s) where you like.

What is copy path clipboard?

Hold down the Shift key, then right-click the photo. 3. In the context menu that appears, find and click Copy as path. This copies the file location to the clipboard. (FYI, if you don't hold down Shift when you right-click, the Copy as path option won't appear.)


2 Answers

Update your code to just return the Path:

(pwd).Path | CLIP

If you're using PowerShell v5 or newer you can use Set-Clipboard instead of clip(.exe).

(pwd).Path | Set-Clipboard
like image 102
henrycarteruk Avatar answered Oct 19 '22 12:10

henrycarteruk


In PowerShell 5.0 and above, you can also use

(pwd).Path | scb

or

scb (pwd).Path

where scb is an alias for Set-Clipboard

Documentation available at https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-clipboard?view=powershell-5.1

like image 12
JY Loh Avatar answered Oct 19 '22 11:10

JY Loh