5

I am running a zsh function to open a .tex file in vim, while opening its related .pdf file in evince. I am currently using xdotool to open a new tab in the current gnome-terminal window, and then executing vim in that tab. I would rather silence the command line output of evince and open vim in the current window.

Unfortunately, with a standard redirect such as evince name.pdf &> /dev/null, evince does not open graphically. Can I run a GUI program from a terminal without having its standard output/error in that terminal?

The function is below:

edittex () { 
    # open a new terminal tab in current terminal
    WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
    xdotool windowfocus $WID
    xdotool key ctrl+shift+t
    wmctrl -i -a $WID
    # open vim in the new terminal tab
    xdotool type "vim [email protected]"
    xdotool key KP_Enter 
    # open evince in old terminal tab
    evince "[email protected]" 
}

Usage: edittex filename, assuming the .pdf and .tex files are named filename.pdf and filename.tex.

1
  • 2
    evince filename &> /dev/null works for me in Zsh. I guess the problem is actually another one.
    – kos
    Mar 11, 2016 at 23:22

1 Answer 1

6

To redirect only stderr of evince to /dev/null and send it to the background at the same time you need to specify:

evince name.pdf 2> /dev/null &

Where :

  • evince name.pdf 2> redirects the output of the errors only
  • /dev/null redirects the output to the null device
  • & sends it the program to the background

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .