Track Current File
Version: 0.0.2
Repository: GitHub: File-Tracker-Extension
Overview
The Track Current File extension for VSCode tracks the currently active file in your editor and automatically updates a fileMetadata.json
file in your workspace directory. This is particularly useful for tools like CLI applications that need context about the active file (e.g., file name, path, or selected lines).
The fileMetadata.json
file is updated dynamically when:
- You switch between files.
- You select or highlight lines in a file.
- You run the
Current File Tracker
command from the Command Palette.
Fields Tracked
The metadata written to fileMetadata.json
includes the following fields:
Field |
Description |
fileName |
The name of the currently active file (e.g., main.go ). |
filePath |
The full path to the currently active file. |
lines |
The range of lines currently selected in the editor (start and end ). If no lines are selected, this value is null . |
timestamp |
The timestamp of the last update in ISO format (e.g., 2025-01-07T20:00:00Z ). |
language |
The language mode of the active file (e.g., javascript , python , go ). |
workspace |
The path to the root of your open workspace. |
fileSize |
The size of the file in bytes. |
lastModified |
The last modified timestamp of the active file in ISO format. |
How It Works
Automatic Updates:
- The
fileMetadata.json
file is automatically updated whenever you:
- Open a new file.
- Switch between files.
- Highlight or select lines in a file.
Command: Current File Tracker
:
- Manually trigger metadata updates using the Command Palette:
- Open the Command Palette (
Cmd+Shift+P
or Ctrl+Shift+P
).
- Search for and select
Current File Tracker
.
- This is useful if you want to ensure metadata is updated on-demand.
Here’s an example of what the fileMetadata.json
file might look like:
{
"fileName": "example.js",
"filePath": "/Users/example/project/example.js",
"lines": {
"start": 5,
"end": 15
},
"timestamp": "2025-01-07T20:00:00Z",
"language": "javascript",
"workspace": "/Users/example/project",
"fileSize": 1456,
"lastModified": "2025-01-07T19:45:00Z"
}
Usage Instructions
Install the extension in VSCode:
- Install the
.vsix
file through the Extensions view in VSCode or download it from the Marketplace.
Run the command once:
- Run the
Current File Tracker
command once from the Command Palette (Cmd+Shift+P
or Ctrl+Shift+P
)
Open any file in your editor:
- The extension will automatically detect the active file and start updating metadata.
Start working:
- The
fileMetadata.json
file will be automatically updated whenever you open a file or select text in the editor.
Notes
- Add
fileMetadata.json
to .gitignore
:
- To avoid tracking workspace-specific metadata in your version control system, add the following line to your
.gitignore
file:
fileMetadata.json
License
This extension is open-source and available under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! If you'd like to contribute, please open an issue or submit a pull request on GitHub.