shell
Install the required plugin:
tynd add shellimport { shell } from "@tynd/plugin-shell/client";Launch URLs / files through the OS’s default handler.
openExternal(url): Promise<void>
Section titled “openExternal(url): Promise<void>”Opens the URL in the default browser.
await shell.openExternal("https://example.com");await shell.openExternal("mailto:hi@example.com");Scheme allowlist — only http://, https://, mailto: are accepted. Passing file://, javascript:, data:, or a registered custom scheme throws.
openPath(path): Promise<void>
Section titled “openPath(path): Promise<void>”Opens a filesystem path in the OS default handler for that file type.
await shell.openPath("/Users/me/document.pdf");await shell.openPath("C:\\Users\\Me\\spreadsheet.xlsx");-
Absolute paths only (relative paths resolve against the app’s cwd, which is unreliable).
-
The OS decides what app handles the file type.
-
Executable and launcher types are refused (the call throws). Only the final extension is checked, case-insensitively, because the OS picks the handler from it:
script.exeis refused,report.exe.txtandapp.js.mapopen with the.txt/.maphandler. On the name, everything from the first:is dropped (NTFS stream suffix such asx.hta::$DATA) and trailing dots and spaces are trimmed first. Refused extensions (133):- Windows executables, scripts and launchers:
exebatcmdcomscrdllpifcplmscmsimspjarps1psm1psc1vbsvbejsjsewsfwshwscscthtalnkurlscfreginfxllgadgetappref-mssettingcontent-msapplicationchmsearch-mslibrary-msdiagcabocxsyswswsbrdpthemethemepackwebsitexbapmhtmhtmljnlpappinstallermsixmsixbundleappxappxbundlesearchconnector-msaccdemdeadpaccdbaccdrvstocercrtderp7b - Interpreter-associated scripts and further script or installer types:
pypywpyzpyzwplpycpyopydrbrbwphppharluatclps1xmlps2ps2xmlpsc2pssccdxmlmshmsh1msh2mshxmlmsh1xmlmsh2xmldrvmsumstmofahkau3vb - Disk images:
isoimgvhdvhdx - macOS:
appcommandtoolterminalworkflowactionscptscptdpkgmpkgdmgfilelocweblocinetlocmobileconfigshortcutprefpanesaverpluginbundleqlgeneratorkext - Linux:
desktopshrunappimagebashzshcshksh
The list applies on every OS.
- Windows executables, scripts and launchers:
-
On Windows, a
:in the file name is refused (the call throws): it names an NTFS alternate data stream (report.pdf:evil.bat), and the OS picks the handler from the stream name. Device paths are refused as well:\\.\...and any\\?\path that is not a drive path or a UNC share (\\?\GLOBALROOT\...,\\?\pipe\...). Both are checked on the path you pass and on the resolved path. On Linux and macOS:is an ordinary file-name character. -
To run a program, use
process.execor a sidecar. -
Returns when the launch is initiated, not when the target app is ready.
revealInFolder(path): Promise<void>
Section titled “revealInFolder(path): Promise<void>”Open the OS file manager with path selected — Windows explorer /select, macOS open -R. On Linux opens the parent directory (no standard “select” gesture across file managers). Like openPath, it goes through the fs policy, throws if the path does not exist, and on Windows refuses a : in the file name and device paths (the extension list does not apply: revealing selects the file, it does not run it).
await shell.revealInFolder("/Users/me/Downloads/report.pdf");beep(): Promise<void>
Section titled “beep(): Promise<void>”Plays the OS alert sound: the Windows default beep, NSBeep on macOS, the GDK display bell on Linux. Resolves at once.
await shell.beep();- To move a file to the trash / recycle bin, use
fs.trash. openPathandopenExternaldo not throw on missing files / unreachable URLs — the OS handler surfaces those errors to the user.openPathdoes throw for a refused file type.
Related
Section titled “Related”- process —
process.execfor more control over what’s launched.