notmuch over ssh

classic Classic list List threaded Threaded
3 messages Options
Keegan Carruthers-Smith Keegan Carruthers-Smith
Reply | Threaded
Open this post in threaded view
|

notmuch over ssh

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
_______________________________________________
notmuch mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: notmuch over ssh

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 -- [hidden email]
To unsubscribe send an email to [hidden email]
Chris Coutinho Chris Coutinho
Reply | Threaded
Open this post in threaded view
|

Re: notmuch over ssh



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 -- [hidden email]
> To unsubscribe send an email to [hidden email]

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
_______________________________________________
notmuch mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]