diff options
| author | Dante Catalfamo | 2020-11-26 16:29:24 -0500 | 
|---|---|---|
| committer | Dante Catalfamo | 2020-11-26 16:29:24 -0500 | 
| commit | 21c7e9e6c0a662a05a70e50309814ed16292a498 (patch) | |
| tree | 4019247559a276aa739e16da4f225f29fa1b3274 /content/posts/org-ssh-export | |
| parent | fdc868f98779adfe68bfc64afb5d2403506fb87a (diff) | |
| download | blog-21c7e9e6c0a662a05a70e50309814ed16292a498.tar.gz blog-21c7e9e6c0a662a05a70e50309814ed16292a498.tar.bz2 blog-21c7e9e6c0a662a05a70e50309814ed16292a498.zip | |
ox-ssh: add bonus elisp
Diffstat (limited to 'content/posts/org-ssh-export')
| -rw-r--r-- | content/posts/org-ssh-export/index.org | 31 | 
1 files changed, 31 insertions, 0 deletions
| diff --git a/content/posts/org-ssh-export/index.org b/content/posts/org-ssh-export/index.org index f9faaad..bf6ae0c 100644 --- a/content/posts/org-ssh-export/index.org +++ b/content/posts/org-ssh-export/index.org @@ -161,3 +161,34 @@ to bring up the org export dispatch, then  @@html: <kbd>s</kbd>@@ to select =Export to SSH config=, and  @@html: <kbd>x</kbd>@@ to overwrite my existing ssh config file with  the newly generated one. + +*BONUS* + +On reddit, user =Funkmaster_Lincoln= [[https://www.reddit.com/r/emacs/comments/k1hfgo/how_i_keep_track_of_my_servers/gdow00y/?context=3][mentioned]] in response to this +post that it would be interesting if one could press a key on the +server heading to connect, without having to add the server to one's +SSH configuration. I had a go at trying to write out what that might +look like, and this is what I came up with. + +#+begin_src emacs-lisp +(defun org-ssh-connect (&optional arg) +  "Connect to the host at point and open `dired'. +If ARG is non-nil, open `eshell' instead of `dired'." +  (interactive "P") +  (let* ((properties (org-entry-properties)) +         (name (alist-get "ITEM" properties nil nil #'string=)) +         (user (alist-get "SSH_USER" properties nil nil #'string=)) +         (port (alist-get "SSH_PORT" properties nil nil #'string=)) +         (host (or (alist-get "IP" properties nil nil #'string=) +                   (alist-get "HOSTNAME" properties nil nil #'string=)))) +    (if host +        (let ((default-directory (format "/ssh:%s%s%s:" +                                         (if user (format "%s@" user) "") +                                         name +                                         (if port (format "#%s" port) "")))) +          (message "Connecting to %s..." name) +          (if arg +              (eshell t) +            (dired "."))) +      (user-error "Not an SSH host")))) +#+end_src | 
