Open Path
Open the best matching link, URL, or file path on the current line with a command or keyboard shortcut.
Open Path is based on the MIT-licensed
Open Target extension by
danbi2990. This fork adds environment-variable expansion, automatic shell
detection, unresolved-variable protection, path inference, and folder opening
in a new VS Code window.
Why This Fork Exists
The original Open Target extension made navigation easier when working with AI
agents that communicate through file references. Open Path keeps that workflow
and extends it for projects that use environment-variable based paths such as
$PROJECT/src/app.ts, plus folder targets that should open as workspaces.
Features
- Open inline Markdown links like
[Guide](https://github.com/xmleee/open-path/blob/HEAD/README.md#commands)
- Open plain URLs like
https://example.com/docs
- Open local file paths like
src/app.ts
- Open local folder paths in a new VS Code window
- Open file locations like
src/app.ts:42 and src/app.ts:42:7
- Open Markdown heading targets like
README.md#getting-started
- Optionally resolve environment variables in local paths, such as
$PROJECT/src/app.ts
- Prefer the target under the cursor when a line contains multiple targets
- If the cursor is not on a target, fall back to the first valid target on the same line
- Work in Markdown and non-Markdown files
- Resolve relative paths from the current file, with a workspace-folder fallback
Relative Path Resolution
Local relative paths are resolved in this order:
- The current document's directory
- The current document's containing workspace folder root, if the first path does not exist
In a multi-root workspace, the fallback uses the workspace folder that contains
the active document, not a global workspace root.
Environment Variables
Environment variable resolution is disabled by default. Enable
open-path.resolveEnvironmentVariables to expand variables before opening
local paths. The extension uses the VS Code extension host environment,
terminal.integrated.env.* settings, and the user's shell environment. If a
path still contains an unresolved variable, Open Path shows a warning instead
of opening it as a relative path.
The shell used for reading variables is detected automatically from the active
VS Code terminal when possible, then from terminal.integrated.defaultProfile.*
and terminal.integrated.profiles.*, then from older terminal shell settings,
and finally from SHELL or ComSpec.
If a leading variable such as $PROJECT/path/to/file cannot be read from the
environment, open-path.inferEnvironmentVariablesFromPaths lets the extension
try ancestor directories from the current file and only accept an inferred value
when the resulting path exists.
Use open-path.environmentVariableFormat to choose the syntax:
dollar: $VAR
braced: ${VAR}
percent: %VAR%
all: all supported formats
Commands
open-path.openPathUnderCursor
Default Keybinding
Cmd+Enter / Ctrl+Enter: open the best matching target on the current line
Next Likely Steps
- Support reference-style markdown links
- Handle titles and escaped parentheses more robustly
- Improve relative path resolution across more non-workspace file cases