open command starts a FastAPI/Uvicorn web server that provides a browser-based markdown editor.
Usage
Arguments
Path to a markdown file or directory containing markdown files.
- File mode: Opens a single
.mdor.markdownfile - Folder mode: Opens a workspace with all markdown files in the directory tree
- Exist on the filesystem
- Be a readable file or directory
- For files: have
.mdor.markdownextension - For directories: contain at least one markdown file (searched recursively)
Options
Host interface to bind the web server to.
127.0.0.1(default) - localhost only0.0.0.0- all network interfaces (required for cloud VMs)localhost- same as 127.0.0.1
cli.py:219-225Preferred starting port for the web server.If the specified port is occupied, the CLI automatically increments to find the next available port in the range 8000-65535.Source:
cli.py:226-232Examples
Terminal Output
When the server starts successfully, you’ll see:Behavior Details
Path Validation
The command validates paths through these checks:- Expansion:
~is expanded to home directory - Resolution: Relative paths are resolved to absolute paths
- Existence: Path must exist on filesystem
- Type detection:
- If file: validates
.mdor.markdownextension - If directory: recursively scans for at least one markdown file
- If file: validates
- File validation:
cli.py:41-59 - Directory validation:
cli.py:79-99 - Unified validation:
cli.py:102-122
Port Selection
Port selection follows this algorithm:- Try to bind to the requested
--port(default 8000) - If occupied, increment by 1 and try again
- Continue until an available port is found (up to 65535)
- Fail if no ports are available in range
cli.py:146-165
Browser Launch
The browser opens in a daemon thread with:- 0.4 second delay (allows server startup)
new=2parameter (opens in new tab)autoraise=True(brings window to front)
cli.py:168-181
Server Modes
cli.py:261-266
Error Messages
Stopping the Server
PressCTRL+C in the terminal to shut down:
Technical Details
- Framework: FastAPI with Uvicorn ASGI server
- Static files: Frontend served from
markdown_os/static/ - File locking: Uses
portalockerfor safe concurrent writes - File watching:
watchdoglibrary monitors filesystem changes - WebSockets: Live updates via
websocketslibrary - Async I/O: All file operations are async-compatible
The
open command is also the default command when markdown-os is invoked without a subcommand. Running markdown-os with no arguments opens the current working directory.