Reputation: 677
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.
Upvotes: 4
Views: 1808
Reputation: 2625
like @Curt Nelson , I use wmctrl
, with with autocmd
and guienter
. It works both on my windows 7 and Ubuntu 13.10.
sudo apt-get install wmctrl
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
Upvotes: 0
Reputation: 3192
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
Upvotes: 5
Reputation: 2263
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.
Upvotes: 2