Skip to content

Commit 3563a29

Browse files
committed
Add codespaces-delete function
1 parent 11b8f9d commit 3563a29

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

README.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ And to disable TRAMP's default ControlMaster settings in your Emacs config, add:
7777
- =codespaces-start= brings up a list of inactive codespaces and upon selection spawns a task that starts the selected codespace.
7878
- =codespaces-stop= does the same but for stopping active codespaces.
7979
- =codespaces-create= prompts for a repository, branch, and machine to then create a Codespace. Default branch is fetched via gh.
80+
- =codespaces-delete= brings up a list of codespaces, and upon selection deletes the selected codespaces.
8081

8182
* Missing features
8283
- Completion should sort codespaces by most-recently-used.

codespaces.el

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ allowing for faster startup. Validation happens lazily on first use."
319319
(or codespaces-default-directory
320320
(format "/workspaces/%s" (codespaces-space-repository-name selected)))))))
321321

322+
(defun codespaces-delete ()
323+
"Delete a codespace chosen by `completing-read`."
324+
(interactive)
325+
(let ((selected (codespaces--complete (codespaces--all-codespaces))))
326+
(when (yes-or-no-p (format "Are you sure you want to delete the codespace '%s'?" (codespaces-space-name selected)))
327+
(shell-command
328+
(format "gh codespace delete -c %s --force" (codespaces-space-name selected))))))
329+
322330
(provide 'codespaces)
323331

324332
;;; codespaces.el ends here

0 commit comments

Comments
 (0)