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

发布于 2024-11-05 10:33:57 字数 940 浏览 4 评论 0原文

我想编写一个 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 仅应在通过此脚本启动时最大化。当然,欢迎任何其他如何实现这一目标的想法。

我使用 Ubuntu 11.04 和 gnome。

感谢您花时间阅读我的消息。

AlexTheBird

此脚本有效:

#!/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 加速)桌面。这对我来说很好。它不适用于使用 Unity 3D 加速版本的默认 Ubuntu 桌面。

I want to write a bash-script that starts a gvim-session directly in a maximized window.

That is my bash-script:

#!/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'

Do you have any ideas how to accomplish this with a bashscript? Gvim should only be maximized when it is started over this script. Any other ideas how to accomplish this are welcome, of course.

I use Ubuntu 11.04 with gnome.

Thank you for taking the time to read my message.

AlexTheBird

This script works:

#!/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';

Thank you all for your time.

EDIT : I just found out that the above solution only works for the unity-2d (non 3D accelerated) desktop. Which is fine for me. It does not work with the default Ubuntu-desktop which uses the 3D accelerated version of Unity.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梓梦 2024-11-12 10:33:57

以下内容适用于 Ubuntu 8.04、Gnome(基于此论坛上的评论):

#!/bin/bash
gvim

sleep 1  # give gvim time to launch

wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz

您可能需要安装wmctrl

sudo apt-get install wmctrl

The following works for me on Ubuntu 8.04, Gnome (based on comments on this forum):

#!/bin/bash
gvim

sleep 1  # give gvim time to launch

wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz

You may need to install wmctrl:

sudo apt-get install wmctrl
憧憬巴黎街头的黎明 2024-11-12 10:33:57

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

gvim -geom 200x50+0+0

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

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

You could use the -geom(etry) option to match the size with the size of your monitor(s).

gvim -geom 200x50+0+0

Where 200 is the number of characters you can fit horizontally, 50 is the same vertically, and +0+0 indicates zero horizontal and vertical offset from the top-left corner of the screen.

Note that the window would not be maximized per se, it would only be (approximately) the same size as your display.

要走就滚别墨迹 2024-11-12 10:33:57

像@Curt Nelson一样,我使用wmctrl,以及autocmdguienter。它适用于我的 Windows 7 和 Ubuntu 13.10。

  1. 安装 wmctrl:sudo apt-get install wmctrl
  2. 将以下脚本添加到您的配置中。

脚本:

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

like @Curt Nelson , I use wmctrl, with with autocmd and guienter. It works both on my windows 7 and Ubuntu 13.10.

  1. Install wmctrl: sudo apt-get install wmctrl
  2. add the following script to your config.

script:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文