summary refs log tree commit diff
path: root/emacs/custom/my-tramp.el
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-06-06 20:22:16 -0700
committerFranck Cuny <franck@fcuny.net>2022-06-06 20:22:16 -0700
commit25bad47612a78b3018cec0622109df3f9a7869ef (patch)
tree19765e6e3308134a17e3be2df5ba5ad22d6e33f5 /emacs/custom/my-tramp.el
parentref(elfeed): remove a bunch of feeds (diff)
downloademacs.d-25bad47612a78b3018cec0622109df3f9a7869ef.tar.gz
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.
Diffstat (limited to 'emacs/custom/my-tramp.el')
-rw-r--r--emacs/custom/my-tramp.el12
1 files changed, 12 insertions, 0 deletions
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