Environment
The Environment APIs are useful to get context about the setup in which your command runs. You can get information about the extension and command itself as well as Raycast. Furthermore, a few paths are injected and are helpful to construct file paths that are related to the command's assets.
API Reference
environment
Contains environment values such as the Raycast version, extension info, and paths.
Example
Properties
Property | Description | Type |
---|---|---|
appearance* | The appearance used by the Raycast application. |
|
assetsPath* | The absolute path to the assets directory of the extension. |
|
commandMode* | The mode of the launched command, as specified in package.json |
|
commandName* | The name of the launched command, as specified in package.json |
|
extensionName* | The name of the extension, as specified in package.json |
|
isDevelopment* | Indicates whether the command is a development command (vs. an installed command from the Store). |
|
launchType* | The type of launch for the command (user initiated or background). | |
ownerOrAuthorName* | The name of the extension owner (if any) or author, as specified in package.json |
|
raycastVersion* | The version of the main Raycast app |
|
supportPath* | The absolute path for the support directory of an extension. Use it to read and write files related to your extension or command. |
|
textSize* | The text size used by the Raycast application. |
|
canAccess* | Returns whether the user has access to the given API. |
|
environment.canAccess
Checks whether the user can access a specific API or not.
Signature
Example
Return
A Boolean indicating whether the user running the command has access to the API.
getSelectedFinderItems
Gets the selected items from Finder.
Signature
Example
Return
A Promise that resolves with the selected file system items. If Finder is not the frontmost application, the promise will be rejected.
getSelectedText
Gets the selected text of the frontmost application.
Signature
Example
Return
A Promise that resolves with the selected text. If no text is selected in the frontmost application, the promise will be rejected.
Types
FileSystemItem
Holds data about a File System item. Use the getSelectedFinderItems method to retrieve values.
Properties
Property | Description | Type |
---|---|---|
path* | The path to the item |
|
LaunchType
Indicates the type of command launch. Use this to detect whether the command has been launched from the background.
Enumeration members
Name | Description |
---|---|
UserInitiated | A regular launch through user interaction |
Background | Scheduled through an interval and launched from background |
Last updated