My standard programming mode is to have a bash shell open on the left side of my desktop and to have emacs open on the right side. However, when I type emacs "filename" in to my shell, it comes up on the left side by default. Anyway I can change this? Thanks!


It's quite straightforward to do this (even though it should be on the right side by default): all you need to do is to experiment with the --geometry option when launching a file. Apart from specifying the size of the emacs window, you can specify offsets to determine window position. It is well explained at the official site:

In the ‘--geometry’ option, {+-} means either a plus sign or a minus sign. A plus sign before xoffset means it is the distance from the left side of the screen; a minus sign means it counts from the right side. A plus sign before yoffset means it is the distance from the top of the screen, and a minus sign there indicates the distance from the bottom.

So, if we want to launch emacs top-right, we run:

emacs file.txt --geometry '-3+3'

Other options such as bottom-left would be '+3-3', etc.

You could just put the above line in your .bashrc as an alias if you want it to launch it like this everytime:

alias emacs='emacs --geometry '-3+3''

After adding the alias, you have to run . .bashrc to source your .bashrc or restart the terminal for it to take effect.

(At any point you can launch emacs with command emacs to run it as normal and the alias will be ignored.)


Various programs respect or disrespect the -geometry flag. Mik's solution happens to not work for me, though your mileage may vary. If it doesn't work for you, you could install the devilspie package. Then make a ~/.devilspie directory and make a file ~/.devilspie/emacs.ds with this content:

( if
  ( matches ( application_name ) "emacs" )
  ( begin    
    ( focus )
    (geometry "755x970+840+0")

You will of course have to edit the numbers in (geometry "755x970+840+0") to something appropriate for your monitor resolution.

Finally, go to Applications>Other>Startup Applications and add devilspie to the programs to run upon startup.

Although this adds an extra dependency, this allows you to have one unified system for controlling the placement of all your applications, (e.g. gnome-terminal, firefox, etc), without having to learn/fight with each application's -geometry or configuration quirks. devilspie also works well with a variety of window managers.

  • Interesting, the geometry option with the offsets did work for me with emacs (as described in my answer), although, as you say, sometimes programs can ignore the flag. – user76204 Jan 9 '13 at 19:34

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.