Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从gnome中的bash脚本启动最大化窗口的gvim_Vim_Gnome - Fatal编程技术网

如何从gnome中的bash脚本启动最大化窗口的gvim

如何从gnome中的bash脚本启动最大化窗口的gvim,vim,gnome,Vim,Gnome,我想编写一个bash脚本,直接在最大化窗口中启动gvim会话 这是我的bash脚本: #!/bin/bash - set -o nounset cd /home/alexthebird/vim-stuff; # directory of the gvim-session file gvim -S bootmap; # start gvim from the sessionfile 'bootmap' 你有没有办法用bash脚本来实现这一点?Gvim只有在通过此

我想编写一个bash脚本,直接在最大化窗口中启动gvim会话

这是我的bash脚本:

#!/bin/bash - 
set -o nounset

cd /home/alexthebird/vim-stuff; # directory of the gvim-session file
gvim -S bootmap;                # start gvim from the sessionfile 'bootmap'
你有没有办法用bash脚本来实现这一点?Gvim只有在通过此脚本启动时才应最大化。当然,任何其他如何实现这一目标的想法都是受欢迎的

我在gnome上使用Ubuntu11.04

感谢您抽出时间阅读我的邮件

亚历克西斯鸟

此脚本有效:

#!/bin/bash - 
set -o nounset
# directory of the gvim-session file
cd /home/alexthebird/vim-stuff;
# -f because of a ubuntu global-menu bug
# -S starts from session-file named 'bootmap'
# -geom solved the problem. see post of Lstor
gvim -geom '200x50+0+0' -f -S bootmap; # start gvim from the sessionfile 'bootmap';
谢谢大家抽出时间

编辑:我刚刚发现上述解决方案仅适用于unity-2d(非3D加速)桌面。这对我来说很好。它不适用于默认的Ubuntu桌面,该桌面使用Unity的3D加速版本。

您可以使用-geom(etry)选项来匹配显示器的大小

其中,
200
是水平方向可容纳的字符数,
50
垂直方向相同,
+0+0
表示屏幕左上角的水平和垂直偏移为零


请注意,窗口本身不会最大化,它只会(大约)与您的显示器大小相同。

以下内容适用于我在Ubuntu 8.04 Gnome上的工作(基于对的评论):

您可能需要安装
wmctrl

sudo apt-get install wmctrl

像@Curt Nelson一样,我使用
wmctrl
,与
autocmd
guienter
一起使用。它可以在我的Windows7和Ubuntu 13.10上运行

  • 安装wmctrl:
    sudo apt get安装wmctrl
  • 将以下脚本添加到配置中
  • 脚本:

    if has("gui_running")
        if MySys() == 'linux'
            autocmd GUIEnter * silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
        else
            winpos 0 0
            set lines=99999 columns=99999
            autocmd guienter * let &columns = 999 | let &columns = &columns/2 
            autocmd guienter * set lines=9999 columns=9999
        endif
    endif
    

    从问题中不清楚哪个部分不适用于您当前的脚本。脚本正在工作。我的问题是,我不知道如何用这个脚本中的最大化窗口启动gvim。这样我就不必在之后最大化gvim窗口。顺便说一句,这个问题在or中会得到更好的答案。你也可以将它添加到你的vimrc中:
    autocmd GUIEnter*winpos 0 0 | set lines=50 columns=200
    或者你可以调用
    gvim-c'winpos 0 0 | set lines=50 columns=200'
    我简直不敢相信。我打算输入“不,我希望窗口最大化”,但-geom选项实际上对unity界面有相同的效果。窗口上边框消失,关闭/min/max按钮连接到全局菜单。谢谢我的意思是窗口标题栏在最后一句中消失了。。。对不起,我的英语不好。谢谢你,科特,但在Ubuntu 11.04中这对我不起作用。由于Ubuntu的全局菜单中有一个bug,在没有-f开关的情况下启动它时,我无法使用gvim的菜单栏。gvim的-f开关使其成为前台进程,因此只有在关闭gvim时才能执行sleep和wmctrl。下面是我所说bug的链接。
    sudo apt-get install wmctrl
    
    if has("gui_running")
        if MySys() == 'linux'
            autocmd GUIEnter * silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
        else
            winpos 0 0
            set lines=99999 columns=99999
            autocmd guienter * let &columns = 999 | let &columns = &columns/2 
            autocmd guienter * set lines=9999 columns=9999
        endif
    endif