unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* notmuch over ssh
@ 2021-02-10  9:52 Keegan Carruthers-Smith
  2021-02-10 10:51 ` Tomi Ollila
  0 siblings, 1 reply; 3+ messages in thread
From: Keegan Carruthers-Smith @ 2021-02-10  9:52 UTC (permalink / raw)
  To: notmuch

Hello.

Thought I'd share a hack I've been using recently. I have my 
notmuch database on another machine. I wanted to access it via my 
local emacs session. I didn't want to ssh in to the machine or 
sync the data to another machine. I realised all communication is 
done via the notmuch binary, so I wrote a wrapper script which 
runs notmuch via ssh:

  #!/usr/bin/env bash  args=()  for var in "$@" do 
      args+=($(printf '%q' "$var")) 
  done  exec ssh real.local -- notmuch "${args[@]}" 

Note I have hardcoded the remote (real.local). I also needed to 
escape arguments since the remote shell had a tendancy to 
interpret them. This escaping isn't fullproof, but has been 
working so far.

I put the above script on my PATH as "notmuch", and emacs 
magically uses it. Alternatively you could set the notmuch-command 
to point to the above shell script.

Cheers,
Keegan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: notmuch over ssh
  2021-02-10  9:52 notmuch over ssh Keegan Carruthers-Smith
@ 2021-02-10 10:51 ` Tomi Ollila
  2021-02-10 11:35   ` Chris Coutinho
  0 siblings, 1 reply; 3+ messages in thread
From: Tomi Ollila @ 2021-02-10 10:51 UTC (permalink / raw)
  To: Keegan Carruthers-Smith, notmuch

On Wed, Feb 10 2021, Keegan Carruthers-Smith wrote:

> Hello.
>
> Thought I'd share a hack I've been using recently. I have my 
> notmuch database on another machine. I wanted to access it via my 
> local emacs session. I didn't want to ssh in to the machine or 
> sync the data to another machine. I realised all communication is 
> done via the notmuch binary, so I wrote a wrapper script which 
> runs notmuch via ssh:

Good stuff !

>
>   #!/usr/bin/env bash  args=()  for var in "$@" do 
>       args+=($(printf '%q' "$var")) 
>   done  exec ssh real.local -- notmuch "${args[@]}" 

In https://notmuchmail.org/remoteusage/

there is an alternative

!/bin/bash
printf -v ARGS "%q " "$@"
exec ssh notmuch notmuch ${ARGS}

(which fork(2)s zero times...)


And then there is my alternative at:

https://github.com/domo141/nottoomuch/blob/master/nottoomuch-remote.rst

(now that I posted that I have to check if it has rotted in last 4 years ;)


Tomi


>
> Note I have hardcoded the remote (real.local). I also needed to 
> escape arguments since the remote shell had a tendancy to 
> interpret them. This escaping isn't fullproof, but has been 
> working so far.
>
> I put the above script on my PATH as "notmuch", and emacs 
> magically uses it. Alternatively you could set the notmuch-command 
> to point to the above shell script.
>
> Cheers,
> Keegan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: notmuch over ssh
  2021-02-10 10:51 ` Tomi Ollila
@ 2021-02-10 11:35   ` Chris Coutinho
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Coutinho @ 2021-02-10 11:35 UTC (permalink / raw)
  To: notmuch



On Wed, 2021-02-10 at 12:51 +0200, Tomi Ollila wrote:
> On Wed, Feb 10 2021, Keegan Carruthers-Smith wrote:
> 
> > Hello.
> > 
> > Thought I'd share a hack I've been using recently. I have my 
> > notmuch database on another machine. I wanted to access it via my 
> > local emacs session. I didn't want to ssh in to the machine or 
> > sync the data to another machine. I realised all communication is 
> > done via the notmuch binary, so I wrote a wrapper script which 
> > runs notmuch via ssh:
> 
> Good stuff !
> 
> > 
> >   #!/usr/bin/env bash  args=()  for var in "$@" do 
> >       args+=($(printf '%q' "$var")) 
> >   done  exec ssh real.local -- notmuch "${args[@]}" 
> 
> In https://notmuchmail.org/remoteusage/
> 
> there is an alternative
> 
> !/bin/bash
> printf -v ARGS "%q " "$@"
> exec ssh notmuch notmuch ${ARGS}
> 
> (which fork(2)s zero times...)
> 
> 
> And then there is my alternative at:
> 
> https://github.com/domo141/nottoomuch/blob/master/nottoomuch-remote.rst
> 
> (now that I posted that I have to check if it has rotted in last 4 years ;)
> 
> 
> Tomi
> 
> 
> > 
> > Note I have hardcoded the remote (real.local). I also needed to 
> > escape arguments since the remote shell had a tendancy to 
> > interpret them. This escaping isn't fullproof, but has been 
> > working so far.
> > 
> > I put the above script on my PATH as "notmuch", and emacs 
> > magically uses it. Alternatively you could set the notmuch-command 
> > to point to the above shell script.
> > 
> > Cheers,
> > Keegan
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org

Have you tried mounting the notmuch database locally using something like sshfs?
I wonder if that's a safer option than all the string escaping you're doing
here.

On the other hand, your network connection would need to be fast enough to allow
this kind of access, and the notmuch versions installed on either machine need
to be compatible.

Chris\r

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-10 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10  9:52 notmuch over ssh Keegan Carruthers-Smith
2021-02-10 10:51 ` Tomi Ollila
2021-02-10 11:35   ` Chris Coutinho

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).