I like having a small terminal for small things (80 x 24), and a big terminal for editing code in vim and such (120 x 38), and sometimes even going full screen, browsing ascci art? I dunno.

Anywho, is there a terminal command that I can use to toggle window sizes for my terminal?


Yes. resize -s <rows> <columns> works with Ubuntu's default terminal application (gnome-terminal).

How to resize the terminal until a program is finished

To get a nice effect of having, say, vim in a specially-sized window only while it's running:

  1. mkdir ~/bin
  2. ~/.profile by default adds ~/bin to the PATH; For now, you can either source ~/.profile or declare the new PATH yourself: export PATH="$PATH":~/bin
  3. vim ~/bin/vim
  4. Add the following:

    source <(/usr/bin/resize -s)
    /usr/bin/resize -s 38 120
    /usr/bin/vim "$@"
    /usr/bin/resize -s $LINES $COLUMNS
  5. Save

  6. chmod +x ~/bin/vim

Now vim will run at size 120×38 and the resizing will be undone when vim finishes.

| improve this answer | |
  • 1
    You rock! : ) Is it possible to get this command to work from within vim as well? I tried !resize -s 38 120 but that didn't work, until I changed a vim flag in my .vimrc, but that made the whole thing choke and do weird graphics things. – Costa Nov 21 '16 at 23:19
  • I suppose I can ctrl + z, and toggle, then fg back to vim : ) – Costa Nov 21 '16 at 23:20
  • 2
    OK, I've added a small section on how to get, say, vim using the same size terminal and then unresizing it after exiting vim. – Chai T. Rex Nov 21 '16 at 23:59
  • This doesn't seem to work when gnome-terminal is maximized or snapped to a side/corner. I'm using 14.04. – wjandrea Nov 22 '16 at 4:06
  • In Vim, you can :set lines=38 columns=120. – Ingo Karkat Nov 22 '16 at 12:06

In Ubuntu 16.10 (and maybe older versions too), if you open a terminal window, and go to the Terminal menu, you can select alternate window sizes directly. In fact, almost exactly the sizes that you are asking for!

Also, F11 will toggle full screen mode.

You can also create multiple profiles that set the screen to exactly the size(s) that you want. Go to the File menu and choose New Profile... call it "My editing profile". Then, when you want to change to a different profile, go to the Terminal menu and choose Change Profile. Then go to the Edit menu and choose Profile Perferences. Set your custom screen size there. Different profiles, each with different screen sizes!

| improve this answer | |
  • 2
    I'm more of a home row keyboard guy : ) This is cool though, thanks!!! – Costa Nov 22 '16 at 5: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.