Ubuntu – terminal command that changes the terminal window dimensions

bashcommand line

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?

Best Answer

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:

    #!/bin/bash
    
    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.