1

I have set up an alias for my mutt: alias mutt='$HOME/.mutt/run-notmuch-offlineimap & ; mutt'.

Note: Changing my Alias to alias mutt='$HOME/.mutt/run-notmuch-offlineimap 2> /dev/null & ; mutt' or to alias mutt='$HOME/.mutt/run-notmuch-offlineimap 2>&1 >/dev/null & ; mutt' produces the exact same result.

The script run-notmuch-offlineimap looks like that:

#!/usr/bin/env zsh

notmuch="$(which notmuch)"

$notmuch new --quiet

$notmuch tag +inbox -- "folder:dev/dev|INBOX or folder:pers/pers|INBOX"
$notmuch tag +sent -- "folder:dev/dev|Sent or folder:pers/pers|Sent"
$notmuch tag +drafts -- "folder:dev/dev|Drafts or folder:pers/pers|Sent"
$notmuch tag +github -- "folder:dev/dev|github and not tag:github"


# test if the offlineimap instance of account dev is already running
if [[ $(pgrep -f 'offlineimap.*dev.*') == "" ]]
then
    offlineimap -c "$HOME/.fetch-send-mail/dev/dev.imap" -u quiet
fi


# test if the offlineimap instance of account dev is already running
if [[ $(pgrep -f 'offlineimap.*pers.*') == "" ]]
then
    offlineimap -c "$HOME/.fetch-send-mail/pers/pers.imap" -u quiet
fi

(the result would be the exact same if I'd used bash in this script)

When i start mutt, this is what happens:

~ 
$ mutt
[1] 31303
Mailbox is unchanged.
# some seconds afterwards:
~ 
$
[1]  + done       $HOME/.mutt/run-notmuch-offlineimap
~ 

The Message "Mailbox is unchanged" is from mutt itself, so that's expected. However, can i prevent the [1] messages to be shown? E.g. when i execute mutt, it should only print this (and nothing else):

~ 
$ mutt
Mailbox is unchanged.
~ 
$

how can i achieve that?

3

If you are in zsh then you can change the alias to launch the background process with &! instead of just &. This will immediately disown the process.

alias mutt='$HOME/.mutt/run-notmuch-offlineimap &! mutt'

If you are in bash then you can use disown after the command to have a similar effect, but you will still get the first job control message listing the pid.

alias mutt='$HOME/.mutt/run-notmuch-offlineimap & disown; mutt'

You can avoid both by using a sub-shell:

alias mutt='($HOME/.mutt/run-notmuch-offlineimap &); mutt'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.