Skip to content

Instantly share code, notes, and snippets.

@gempesaw
Last active December 13, 2015 17:09
Show Gist options
  • Select an option

  • Save gempesaw/4945527 to your computer and use it in GitHub Desktop.

Select an option

Save gempesaw/4945527 to your computer and use it in GitHub Desktop.
reset-ssh-connections
(require 'dash)
(defun reset-ssh-connections ()
(interactive)
(let ((tramp-buffers
(-filter (lambda (item)
(string-match "tramp" (buffer-name item)))
(buffer-list))))
(while tramp-buffers
(kill-buffer (car tramp-buffers))
(setq tramp-buffers (cdr tramp-buffers))))
(delete-hung-ssh-sessions))
(defun delete-hung-ssh-sessions ()
(interactive)
(let ((cm-socket-files (directory-files "~/.ssh/cm_socket" nil nil t)))
(while cm-socket-files
(let ((filename (car cm-socket-files)))
(if (not (or (string= "." filename)
(string= ".." filename)))
(delete-file (concat "~/.ssh/cm_socket/" filename)))
(setq cm-socket-files (cdr cm-socket-files))))))
(global-set-key (kbd "C-s-r") 'reset-ssh-connections)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment