From 25bad47612a78b3018cec0622109df3f9a7869ef Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 6 Jun 2022 20:22:16 -0700 Subject: feat(tramp): add function to quickly ssh to a machine Add a list of hosts I ssh to frequently. This list is used by the function `my/ssh-cd-home' to make it easy to open a dired buffer on that machine. --- emacs/custom/my-tramp.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'emacs/custom') diff --git a/emacs/custom/my-tramp.el b/emacs/custom/my-tramp.el index ed343bc..897d48c 100644 --- a/emacs/custom/my-tramp.el +++ b/emacs/custom/my-tramp.el @@ -8,5 +8,17 @@ (customize-set-variable 'tramp-histfile-override t) (customize-set-variable 'tramp-ssh-controlmaster-options "-o ControlMaster=auto -o ControlPath='tramp.%%C'") +(defcustom my/ssh-hosts '("192.168.0.1:9922" + "192.168.0.106") + "List of hosts I regularly connect to." + :type '(repeat string) + :group 'tramp) + +(defun my/ssh-cd-home () + "Prompt for an SSH host and open a DIRED buffer on that machine." + (interactive) + (let ((machine (completing-read "Machine: " my/ssh-hosts))) + (find-file (format "/ssh:%s:~" machine)))) + (provide 'my-tramp) ;;; my-tramp.el ends here -- cgit 1.4.1