Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use emacs fairly regularly and am trying to configure my system to use emacsclient when possible. To do this I have done the following:

In .bashrc:

EDITOR='emacsclient -ca emacs'
VISUAL='emacsclient -ca emacs'

I then also installed an alternative for /usr/bin/editor that points to /usr/local/bin/emacsclient.wrapper that has the following:

 #!/bin/sh
 #Start emacs client
 /usr/bin/emacsclient -ca emacs $1

For the most part this works great. However, when emacsclient is launched from the terminal, it often spews out text I don't need. Notably:

$ editor 
Waiting for Emacs...
$ 

Or, when emacs isn't already started and emacclient has to fall back to starting emacs itself:

emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

What can I do to surpress this output? I've tried changing my emacs wrapper to

     #!/bin/sh
     #Start emacs client
     /usr/bin/emacsclient -ca emacs $1 &> /dev/null

but this didn't help. I didn't try editing EDITOR or VISUAL since I don't have any ideas other than this standard redirection.

share|improve this question
    
Replace $1 by "$@". The quotes are needed to pass file names containing spaces and other special characters, and "$@" will pass all arguments to emacsclient in case you ever want to edit several files at once or pass +LINE FILENAME to open a file at a certain line number. –  Gilles Sep 6 '10 at 20:44
add comment

1 Answer 1

up vote 4 down vote accepted

In general:

program >/dev/null 2>&1

will force the output (STDOUT) of program to /dev/null and redirects STDERR to STDOUT. So try:

/usr/bin/emacsclient -ca emacs $1 >/dev/null 2>&1
share|improve this answer
2  
Gah! Immediately upon reading your response did I realize that &> is a bashism and was never going to work with #!/bin/sh. –  Steven D Sep 6 '10 at 7:14
    
@Steven Oh, good call. I tried it in sh to make sure, but sh is symlinked to bash on my computer –  Michael Mrozek Sep 6 '10 at 7:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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