Skip to content

Instantly share code, notes, and snippets.

@epichub
Created August 7, 2024 09:11
Show Gist options
  • Save epichub/670be484291a037c3f82d9c24cec82fb to your computer and use it in GitHub Desktop.
Save epichub/670be484291a037c3f82d9c24cec82fb to your computer and use it in GitHub Desktop.
(defun epicemacs/save-and-kill-tramp-buffers ()
(interactive)
(let* (
(filter "\*") ;; not any meta buffers such as #<buffer *tramp/ssh rootepicvps*> - let them be
(ssh-buffers (seq-filter (lambda (buf)
(not (string-match-p filter (buffer-name buf))))
(tramp-list-remote-buffers)))
(ssh-buffer-names (mapcar #'buffer-name ssh-buffers))
(prettylist (mapconcat 'identity ssh-buffer-names " "))
)
(message "killing tramp buffers: %s" prettylist)
(mapcar #'save-buffer ssh-buffers)
(mapcar #'kill-buffer ssh-buffers)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment