11

It used to be that Ctrl + - and Ctrl + + would increase or decrease the text size of the terminal in earlier versions of Ubuntu, which is helpful when you're giving presentations and want to show your code in a larger size. I switched to Xubuntu 12.04, and I'm missing these keyboard shortcuts.

Is there an alternative I can use? Or if not, is there a way I can define my own shortcut to replace these?

Update: Happy to report that this question is now moot for recent versions of xfce4-terminal! See here.

8 Answers 8

5

Instead of relying on Python and missing modules, as in Noah K. Tilton's github solution, I drafted up a bash script that's a step closer to being more portable (at least, for installations using the most generic, default paths).

You may need to tweak the script to setup your xfce configuration path, your favourite font, etc.

Just 2 files, dropped into my home's ~/bin folder, "zoomin" and "zoomout". I didn't go further than making short commands that I can type quickly, so I don't have a clue how I'd be able to configure these scripts to respond ONLY when I'm inside of xfce4-terminal -- meaning that I gave up thinking about how to get the keybindings made for Ctrl+- and Ctrl++ because I currently only know about global keyboard bindings and didn't want to override those Keypress Combos since other applications will need them (ex: web browser, text editor).

I also thought about having "zoommin" and "zoommax", to jump to my smallest and biggest fonts when needed, typically when I need to see tons of text VS when I need to show a colleague something on my screen. I'll leave those two scripts up to your imagination on how to create :P

~/bin/zoomin

#!/bin/bash
SIZE=`grep 'FontName' ~/.config/xfce4/terminal/terminalrc | cut -d' ' -f 2`
NEWSIZE=$((SIZE + 2))
REGEXPR='s/FontName.*/FontName=Monospace '$NEWSIZE'/g'
sed -i "$REGEXPR" ~/.config/xfce4/terminal/terminalrc

~/bin/zoomout

#!/bin/bash
SIZE=`grep 'FontName' ~/.config/xfce4/terminal/terminalrc | cut -d' ' -f 2`
NEWSIZE=$((SIZE - 2))
REGEXPR='s/FontName.*/FontName=Monospace '$NEWSIZE'/g'
sed -i "$REGEXPR" ~/.config/xfce4/terminal/terminalrc
5
  • Not sure I follow what you mean by "missing modules" - my python script uses the standard library. I think bash/python portability is a toss-up. However, yours might be more performant - at the cost of some readability.
    – user70382
    Mar 10, 2014 at 16:51
  • I experienced this among other things. Noah K was, all fairness granted, against tweaking his script to make life easier for *buntu users. I simply reverse-engineered the thing to be a little more universal, removing the python requirement altogether. :3
    – starlocke
    Mar 10, 2014 at 20:09
  • you reported a bug on XDG_CONFIG_PATH - a string that doesn't appear in my script. Huh? Assuming you meant XDG_CONFIG_HOME, which does appear in my script, you might want to check out superuser.com/questions/365847/… which basically says it's up to the user to define it. Not sure what the "other things" were :) Opinions may differ, but I think 1 parameterized python script is a little cleaner than 2 bash scripts.
    – user70382
    Mar 10, 2014 at 22:29
  • 1
    it it's about a short readable text change I would suggest perl perl -pi -e 's/(FontName.*)(\d+)/$1.($2+2)/e' ~/.config/xfce4/terminal/terminalrc rather than fiddling with the bash
    – Hachi
    Sep 26, 2014 at 7:48
  • 1
    Cool, based on this, I created three methods which I add in my ~/.bash_aliases file: zi, zo and z, which each takes as first argument either steps to zoom (zi and zo), or destination font size (z): gist.github.com/samuell/107a498821c88426fa5a . So, to set text size to 12, I would do z 12, and to zoom in one step, I would do zi 1. Oct 3, 2014 at 14:55
4

Update: as of this commit, resizing is now supported with Ctrl++ and Ctrl+-, which obsoletes my question.

The other answers in this thread are still valuable if you're using older versions of xfce4-terminal.

2
  • 1
    On an en_US keyboard, you need Ctrl+Shift+= to get bigger and Ctrl+- to get smaller. Neither Ctrl+= nor Ctrl+Shift+- will work, nor will the keypad + and -, which is too bad.
    – Adam Katz
    Oct 25, 2017 at 21:46
  • Update: xfce4-terminal issue 55 requests support for Ctrl+= and the keypad variations of +, -, and 0. I encourage folks to log in with a Github or Gitlab.com (or local XFCE Gitlab) account and upvote it (but let's not pollute it with comments).
    – Adam Katz
    Sep 8, 2020 at 19:23
3

The shortcuts you mention are for gnome-terminal, the default terminal used by gnome (and, what follows, by standard Ubuntu). XFCE, which is the main environment in Xubuntu, has its own terminal implementation. However, as far as I can tell, it is not possible in xfce4-terminal to change the font size with a shortcut (you can see the list of possible shortcuts when you go to Edit->Preferences->Shortcuts).

If you rely on this feature, you can install gnome-terminal, but since the whole point of using XFCE is often that it does not involve the somewhat heavy Gnome libraries, this might be a little unproductive.

5
  • Thanks for the answer. How disappointing, though! :( Oct 8, 2012 at 15:00
  • Well, XFCE is supposed to be lean and fast, so naturally they had to give up on features.
    – January
    Oct 8, 2012 at 15:02
  • @January I think your answer sells this question a bit short, please see my answer below.
    – user70382
    May 30, 2013 at 7:20
  • @g33kz0r nah, starlocke (the accepted answer) made already a good case.
    – January
    Mar 10, 2014 at 9:38
  • @January, well that was posted after my answer :)
    – user70382
    Mar 10, 2014 at 16:50
2

While the rest of the answers here require you to create some type of 'hack' using custom scripts, which may or may not break when doing upgrades to your system, the actual/other answer was found in a StackOverflow question here:

Can vim zoom in and out?

By user: Chenming Zhang

Edit > Preferences > Appearance

You will see the option: Font

Which contains both the chosen font and the size of the font-text.

I know that you are looking for a 'shortcut', but all the other options seem to require lots of customization, whereas going this route will ensure that you don't screw up your Terminal with any customizations.

This answer is also being posted here for anybody that needs an alternate option to ctrl +- for zooming in/out.

1

It is possible, though not through xfce4 proper, using this workaround:

https://github.com/noah/xfce4-terminal-font

(requires python).

I use it in awesome window manager like this:

awful.key({ "Control", "Shift" }, "Up", function () awful.util.spawn(script_dir .. "/xfce4-terminal-font +", false)end),
awful.key({ "Control", "Shift" }, "Down", function () awful.util.spawn(script_dir .. "/xfce4-terminal-font -", false)end),

It's a bit of a hack, but it works.

2
  • This has the same drawback as the answer from @starlocke (who also mentioned that it is Noah's solution): it creates a windowmanager shortcut, not a terminal shortcut. Since ctrl-shift-up or ctrl-shift-down are fairly common key combinations (not to mention the more typical ctrl + and ctrl - shortcuts used to change font size for example in gnome-terminal), it might lead to shortcut collisions and / or lack of consistency.
    – January
    Mar 10, 2014 at 9:39
  • All true ... but I don't think collision is that big of a deal - if it collides, just change the shortcut ... I would also note that OP didn't ask for a terminal shortcut - he just asked generally how to do it - and your answer that "it is not possible in xfce4-terminal to change the font size with a shortcut" is inaccurate.
    – user70382
    Mar 10, 2014 at 16:53
0

The following script checks if Xfce4 Terminal is running. If it is not, the script exits. This script uses arguments, script-name --in to zoom in and script-name --out to zoom out. It will work for any font type. (Different font types have a different number of words.)

I named my script terminal-zoom, and I am using Ctrl Alt + for terminal-zoom --in and Ctrl Alt - for terminal-zoom --out.

#!/bin/bash

# Check if Xfce4 Terminal is running. If it is not, exit.
status=$(pgrep xfce4-terminal)

if [ -z "$status" ]; then
    notify-send "No Xfce4 Terminal session is open."
    exit 1
fi

# 1. Get the full line. 2. Get the entire line minus font size. 3. Get only font size. 
line=$(grep "FontName" ~/.config/xfce4/terminal/terminalrc)
font_name=$(echo "$line" | sed s/'\w*$'//)
font_size=$(echo "$line" | grep -oE '[^ ]+$')

# Increase or decrease font size. You might want to change this to increase and decrease by two.
if [ "$1" = "--in" ]; then
    new_size=$((font_size + 1))
elif [ "$1" = "--out" ]; then
    new_size=$((font_size - 1))
else
    notify-send "Argument options: --in --out"
    exit 1
fi

# Replace the line with the new font size.
action='s/'$font_name$font_size'/'$font_name$new_size'/'
sed -i "$action" ~/.config/xfce4/terminal/terminalrc

# Show the new current font being used.
notify-send -t 200 "$new_size pt font"
0

There are currently no zoom-shortcuts offered by xfce-term. Consider Terminator, which is lightweight on dependencies (unlike Gnome-term) and offers zoom-in and out via CTRL+SHIFT+"+"

0

This an old thread but was curious on how others did this. I'm using i3-wm and wrote this script to use with it

#!/bin/bash

TRC=~/.config/xfce4/terminal/terminalrc
OldLine=$(grep FontName $TRC)
FontSize=$(echo $OldLine |sed 's/FontName=.* \([[:digit:]]\+\)/\1/g')
OldFont=$(echo $OldLine | sed 's/\(FontName=.*\) [[:digit:]]\+/\1/g')

if [ "$1" == "in" ] 
    then
        FontSize=$((FontSize+1))
fi

if [ "$1" == "out" ]
    then
        FontSize=$((FontSize-1))
fi

if [ "$1" == "reset" ]
    then
        FontSize=11
fi

NewLine="$OldFont $FontSize"
sed -i "s/$OldLine/$NewLine/g" $TRC

I improved it looking at the script by someone else in here

#!/bin/bash

#Check if xfce4-terminal is running, If not exit.
Status=$(pgrep xfce4-terminal)
if [ -z "$Status" ] 
    then
        exit 1
fi

TRC=~/.config/xfce4/terminal/terminalrc
OldLine=$(grep FontName $TRC)
FontSize=$(echo $OldLine |sed 's/FontName=.* \([[:digit:]]\+\)/\1/g')
OldFont=$(echo $OldLine | sed 's/\(FontName=.*\) [[:digit:]]\+/\1/g')

if [ "$1" == "in" ] 
    then
        FontSize=$((FontSize+1))
fi

if [ "$1" == "out" ]
    then
        FontSize=$((FontSize-1))
fi

if [ "$1" == "reset" ]
    then
        FontSize=11
fi

NewLine="$OldFont $FontSize"
sed -i "s/$OldLine/$NewLine/g" $TRC

You must log in to answer this question.

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