A simple VS Code extension that adds a button to the editor title bar for copying the relative path of the active file to the clipboard.
- One-click path copying: Click the copy button in the editor title bar to instantly copy the relative path of the currently opened file.
- Visual feedback: After successful copying, the button icon changes to a checkmark for 3 seconds to confirm the action.
- Active tab aware: The editor title button shows based on the active tab, not only when the text area has focus.
- Status bar button: A status bar button is always available so you can copy even when focus is on the sidebar (e.g., Chat view).
- Workspace awareness: Automatically detects if you're in a workspace and copies relative or absolute paths accordingly.
- No configuration needed: Works out of the box with no additional settings required.
- Choose your mode quickly: Use Alt/Option-click on the editor title button, a status bar QuickPick, or keybindings to copy either plain path or path with line:column on demand.
- Open any file in VS Code
- Use one of the options below:
- Editor title button: click to copy the path; Alt/Option-click to copy
path:line:column. - Status bar: click
$(copy) Pathto open a QuickPick and choose between plain path orpath:line:column. - Commands/Keybindings:
Copy Relative Path(Cmd+Alt+Con macOS /Ctrl+Alt+Con Windows/Linux) orCopy Relative Path (with Line:Column)(Cmd+Alt+Shift+C/Ctrl+Alt+Shift+C).
- Editor title button: click to copy the path; Alt/Option-click to copy
- The path is now in your clipboard, ready to paste
- From Marketplace: kazoottt.copy-relative-path-button
- From GitHub Releases (VSIX): Latest release
- Download the
.vsixfile from the latest release - Open VS Code
- Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) - Type "Extensions: Install from VSIX"
- Select the downloaded
.vsixfile
- Clone this repository
- Run
npm installorpnpm install - Run
npm run compileorpnpm run compile - Press
F5to open the extension in development mode
To contribute or modify the extension:
git clone <repository-url>
cd copy-relative-path-button
pnpm install
pnpm run compile
# Then press F5 in VS Code to test- Initial release with copy relative path functionality and visual feedback system
- Add second command to copy with
line:column - Editor title button supports Alt/Option-click to copy with position
- Status bar button shows QuickPick to choose mode
Enjoy copying relative paths effortlessly!
