Skip to content

Instantly share code, notes, and snippets.

@t-mat
Last active January 23, 2025 09:15
Show Gist options
  • Save t-mat/38c6b8650be95beb44488bcaf4515e82 to your computer and use it in GitHub Desktop.
Save t-mat/38c6b8650be95beb44488bcaf4515e82 to your computer and use it in GitHub Desktop.
[Windows] echo clickable path as URL in pwsh, PowerShell and cmd.exe

Echo Ctrl + click-able hyperlink to the Windows Terminal

PowerShell & pwsh (PowerShell 5 & 7)

$my_path = $pwd
Write-Output "file:///$($my_path -replace '\\','/')"

$my_url = $my_path -replace '\\','/'
Write-Output "file:///${my_url}"

Batch file

set "MY_PATH=%CD%"
echo file:///%MY_PATH:\=/%

set "MY_URL=%MY_PATH:\=/%"
echo file:///%MY_URL%

See also

https://learn.microsoft.com/en-us/windows/terminal/tips-and-tricks#open-a-hyperlink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment