3 # Run notmuch on remote host over SSH
5 # https://notmuchmail.org/remoteusage/
7 # Put this script in your path and add (setq notmuch-command
8 # "notmuch-remote") to your emacs configuration.
10 # Add a host specification for "notmuch" to ~/.ssh/config to set the
11 # remote host and (optionally) remote user.
14 # HostName host.example.org
17 SSH_REMOTE_HOST=notmuch
19 # Note: for security reasons the control socket is placed in ~/.ssh
20 SSH_CONTROL_PATH='-o ControlPath=~/.ssh/notmuch-remote.%r@%h:%p'
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}
26 # The ControlPersist option (in OpenSSH 5.6) could be used to start
27 # the master connection automatically when "ssh host notmuch" is run.
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}