feat(md): add an md wrapper for MarkText, with an optional read-only sandbox #151
No Reviewers
Labels
Clear labels
Area/CI
Area/Completions
Area/Components
Area/Config
Area/Docs
Area/Functions
Area/Integrations
Area/Prompt & Theme
Area/Scripts
Area/Tests
Compat/Breaking
Kind/Bug
Kind/Chore
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Performance
Kind/Refactor
Kind/Security
Kind/Testing
good first issue
help wanted
.github/workflows and repository automation
completions/ - tab-completion scripts
The opinionated-component system (C1-C6)
config.fish and conf.d/ - startup and environment
docs/manual/ and the generated manual, man page, and site
functions/ - user-facing functions and helpers
integrations/ - third-party tool wiring
themes/ and prompt appearance
scripts/ - standalone helper scripts
tests/ - the syntax lint and functional suite
Breaking change that won't be backward compatible
Something is not working
Tooling, dependencies, and housekeeping
Documentation changes
Improve existing functionality
New functionality
Makes existing behavior faster or lighter
Restructures code without changing behavior
This is security issue
Issue or pull request related to testing
Well-scoped and self-contained; a good place to start
Maintainer is looking for someone to pick this up
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Milestone
No items
No Milestone
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: rootiest/fish-config#151
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
Adds
md, a wrapper that launches MarkText detached from the terminal, and registersmarktextandfirejailas Optional-tier dependencies offish-deps.mdforwards every argument tomarktextuntouched except two flags of its own:-r,--read-only--foregroundFlags whose entire purpose is terminal output —
--version,-v/--verbose,--debug— imply--foreground, since backgrounding them would send the requested output to/dev/null.The read-only sandbox
MarkText has no read-only mode, so
-rbinds each named file read-only with firejail. The non-obvious part is that MarkText is single-instance: a plain sandboxed launch hands the file to an already-running — unsandboxed, writable — window and exits, silently defeating the sandbox.-rtherefore also passes a private--user-data-dir, which forces an independent instance that the read-only bind actually covers, plus--no-sandbox, since Electron's own sandbox needs the user namespaces firejail has already taken away.Verified against the real binaries:
firejail --read-only=<file> marktext --no-sandbox --user-data-dir=<dir> --versionlaunches, and a write to a--read-only-bound file inside the sandbox fails withPermission denied, leaving the file unchanged.Why no conf.d file and no opinionated guard
mdis autoloaded, so it can never shadow anmdfunction or alias defined elsewhere — fish only looks infunctions/when nothing namedmdalready exists. A realmdbinary would be shadowed, so the body hands the name straight back to it whenevermarktextis not installed. No guard variable and no source-time gating are needed for either case.It also carries no C1 guard:
mdis a novel command name rather than a command shadow, the same asbkganddetach.Dependencies
Both new entries are Optional tier (skipped unless
fish-deps install --optional/--all).firejailis a plain system package everywhere.marktextis not — upstream ships an AUR package and its own GitHub release assets, and no distro carries it under a common name — so its_fdc_pmentry is deliberately empty and amarktext-releasespecial offers:paru/yay -S marktext-binwhere an AUR helper is present~/.local/bin/marktextThe release assets embed their version in the filename, so there is no stable
/releases/latest/downloadURL;_fish_deps_marktext_appimagereads the download URL from the GitHub API. Upstream builds the Linux AppImage for x86_64 only, and the helper says so rather than downloading an unusable binary.fish-deps updaterefreshes marktext through the AUR where available, and otherwise only when~/.local/bin/marktextexists — a distro-packaged marktext belongs to that package manager, and dropping an AppImage into~/.local/binwould shadow it.Testing
New
tests/test-md.fish(16 assertions) stubsmarktext,firejailandbkgas functions that print their arguments, so it asserts on the assembled command line without launching an editor and passes on a machine that has none of the three installed. It covers flag forwarding, flag stripping, the implied-foreground set, relative-path resolution for the firejail bind, the private user-data directory, and the failure when-rnames no existing file.Full suite: 249/249 syntax, 249/249 indent,
test-md16/16. The 6 pre-existingmkrepassertion failures onmainare unchanged by this branch.Docs
docs/manual/06-dependency-catalog.mdgains a row for each new dependency;md's manual entry is generated from its header comment.docs/fish-config.mdanddocs/fish-config.1are regenerated.d9dec4c11dtof153a3db87