3

In the default Terminal app the current width and height of the window are always displayed in the title bar, whereas in iTerm2 they're only displayed for a few moments when resizing.

How can I change it so that they're always visible in iTerm2 too?

3 Answers 3

5

Can't find the correct variable for the title. But if you go to iTerm2-> Preferences -> Profiles -> Session -> Configure Session, you can create a custom menu component with title as \(rows) x \(columns) and it will show the width. I know it's not the perfect solution but will do your job.

enter image description here

Make sure your status bar enabled is checked.

3
  • 2
    You were on the right track, going to iTerm2 -> Preferences -> Profiles -> General -> Name and changing the name to \(columns) x \(rows) does the job.
    – noibe
    Commented Aug 20, 2019 at 12:02
  • Actually now I have the opposite problem, when I resize the terminal dimensions are displayed twice. Do you know how to not to show the dimensions when resizing?
    – noibe
    Commented Aug 20, 2019 at 12:08
  • I could not find an easy way to do this except write a custom script to change the behavior of the windows resizing. I will try this later and update here if I succeed.
    – anshu957
    Commented Aug 20, 2019 at 16:55
1

If you're using zsh you can also override your title bar's content by adding a precmd() function like the following to your ~/.zshrc.

precmd()
{
  echo -ne "\e]1;$(dirs -p | head -1) - $COLUMNS\x78$LINES\a"
}

Resulting window title e.g.: ~/Projects - 80x24

Segment Effect
precmd() Always called just before a new prompt is shown.
echo -n Omits the default newline (necessary).
echo -e Ensures escape sequences are processed.
\e]1;TEXT\a [ESCAPE] ]1; TEXT [AUDIBLE-BELL] - the necessary escape sequence to change the window title.
$(dirs -p | head -1) Current working directory using ~; e.g. ~/Projects
$COLUMNS\x78$LINES COLUMNS and LINES are shell variables. \x78 is the hexadecimal code for x - if we wrote $COLUMNSx$LINES then the shell would be looking for COLUMNSx as a variable.

Caveat: altered dimensions only change in the window title after you run a command.

0

Building on noibe's previous comment, here's a way to accomplish it within the current version of iTerm2 (3.14.19).

Check Preferences > Profiles > Window > Custom window title and enter something like:

\(currentTab.currentSession.path) \(currentTab.currentSession.columns)x\(currentTab.currentSession.rows)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .