Alfred workflow to start/stop workspaces on Coder
- Download zip
- Unzip
- Double-click alfred-coder.alfredworkflow and import to Alfred
- Right-click on the workflow and select "Open in Terminal"
- Install dependencies by running npm install
- Copy example.env to .env and assign values to all the variables
cp example.env .env
nano .env
You will need to have the coder cli installed and configured. We're also going to be using the Coder API to get workspaces, so you will also need to create a Coder API key by running the following command in your terminal:
coder tokens create api_key
Note: We are using the API to get the workspaces, rather than the coder cli, because the API is much faster.
Search for a workspace with the coder
or cdr
keywords. Select the workspace to start/stop it.
There are also tasks that you can use in addition to starting/stopping the workspace.
-
cdr workspace
- display the given workspaces with any commands that may be available. Certain commands will only be available if the workspace is running. -
cdr stop workspace
- stop the given workspace -
cdr start workspace
- start the given workspace and open the frontend in the browser -
cdr rebuild workspace
- rebuild the given workspace -
cdr view workspace
- open the frontend of given workspace in the browser. You can specify the base url with theAPP_USER
andBASE_URL
environment variables. -
cdr code workspace
- open the code for the given workspace in the browser in your editor of choice. You can specify the editor with theEDITOR
environment variable. -
cdr term workspace
- open the terminal for the given workspace in the browser. -
cdr stop:all
- stop all workspaces
- Coder Workspaces API - https://apidocs.coder.com/#operations-tag-Workspaces
- Coder CLI - https://github.com/coder/coder-cli