]> git.cworth.org Git - notmuch-wiki/blob - remoteusage/remotewrapper.mdwn
Ah, referrers are linked!
[notmuch-wiki] / remoteusage / remotewrapper.mdwn
1     #!/bin/bash
2     
3     # Run notmuch on remote host over SSH
4     #
5     # http://notmuchmail.org/remoteusage/
6     #
7     # Put this script in your path and add (setq notmuch-command
8     # "notmuch-remote") to your emacs configuration.
9     #
10     # Add a host specification for "notmuch" to ~/.ssh/config to set the
11     # remote host and (optionally) remote user.
12     #
13     # Host notmuch
14     #     HostName host.example.org
15     #     User username
16     
17     SSH_REMOTE_HOST=notmuch
18
19     # Note: for security reasons the control socket is placed in ~/.ssh
20     SSH_CONTROL_PATH='-o ControlPath=~/.ssh/notmuch-remote.%r@%h:%p'
21     
22     # Start a background master connection if one isn't running yet
23     ssh ${SSH_CONTROL_PATH} -O check ${SSH_REMOTE_HOST} 2>/dev/null ||
24     ssh ${SSH_CONTROL_PATH} -MNf ${SSH_REMOTE_HOST}
25     
26     # The ControlPersist option (in OpenSSH 5.6) could be used to start
27     # the master connection automatically when "ssh host notmuch" is run.
28     
29     # This requires the bash version of printf (bashism)
30     printf -v ARGS "%q " "$@"
31     exec ssh ${SSH_CONTROL_PATH} ${SSH_REMOTE_HOST} notmuch ${ARGS}