以特定方式启动终端?

时间:2010-11-23 20:35:45

标签: linux bash unix gnome-terminal

我正在尝试编写一个脚本,让我在屏幕上的特定位置启动一组特定大小的终端(例如,四个终端在网格模型中分布在每个活动的网格模型中)。如果已经有一个可以做到这一点的工具,那也会很棒......有什么建议吗?

2 个答案:

答案 0 :(得分:3)

我确信会有更好的答案,但我发现有用的一件事是:

gnome-terminal --geometry=130x25+20+525

所以在我的大显示器上,以下是给我两个不错的终端:

#!/bin/sh

gnome-terminal --geometry=150x125+20+25
gnome-terminal --geometry=150x125+1020+25

以下是man page的解释,以供快速参考:

   -geometry WIDTHxHEIGHT+XOFF+YOFF 

   (where WIDTH,  HEIGHT,  XOFF,
   and  YOFF are numbers) for specifying a preferred size and location for
   this application's main window.

   The WIDTH and HEIGHT parts of the geometry  specification  are  usually
   measured  in either pixels or characters, depending on the application.
   The XOFF and YOFF parts are measured in pixels and are used to  specify
   the  distance  of  the window from the left or right and top and bottom
   edges of the screen, respectively.  Both types of offsets are  measured
   from  the indicated edge of the screen to the corresponding edge of the
   window.  The X offset may be specified in the following ways:

   +XOFF   The left edge of the window is to be placed XOFF pixels in from
           the left edge of the screen (i.e., the X coordinate of the win-
           dow's origin will be XOFF).  XOFF may  be  negative,  in  which
           case the window's left edge will be off the screen.

   -XOFF   The  right  edge  of  the window is to be placed XOFF pixels in
           from the right edge of the screen.  XOFF may  be  negative,  in
           which case the window's right edge will be off the screen.

   The Y offset has similar meanings:

   +YOFF   The  top  edge of the window is to be YOFF pixels below the top
           edge of the screen (i.e., the Y coordinate of the window's ori-
           gin  will  be  YOFF).   YOFF may be negative, in which case the
           window's top edge will be off the screen.

   -YOFF   The bottom edge of the window is to be YOFF  pixels  above  the
           bottom edge of the screen.  YOFF may be negative, in which case
           the window's bottom edge will be off the screen.

这种方法很简单,使用如下命令:

gnome-terminal -x sh -c "ls|less"

除了上面的命令之外,还可以做更多花哨的事情:)例如,你可以让它自己启动到一个特定的目录(如果你在一个窗口中编辑源代码并使用另一个窗口进行调试,这非常有用)就像我一样。)

答案 1 :(得分:1)

终结者是一个解决这个问题的项目:https://github.com/achiu/terminitor

不幸的是,它还没有gnome-terminal支持(只是OS X和Konsole)。