Skip to content

Instantly share code, notes, and snippets.

@samuell
Created October 3, 2014 14:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save samuell/107a498821c88426fa5a to your computer and use it in GitHub Desktop.
Save samuell/107a498821c88426fa5a to your computer and use it in GitHub Desktop.
Place this in your ```~/.bash_aliases``` file.
zi() {
if [[ ! -z $1 ]]; then
steps=$1;
SIZE=`grep 'FontName' ~/.config/Terminal/terminalrc | cut -d' ' -f 2`
NEWSIZE=$((SIZE + steps))
REGEXPR='s/FontName.*/FontName=Monospace '$NEWSIZE'/g'
sed -i "$REGEXPR" ~/.config/Terminal/terminalrc
else
echo "Usage: zi [zoom steps]";
fi;
}
zo() {
if [[ ! -z $1 ]]; then
steps=$1;
SIZE=`grep 'FontName' ~/.config/Terminal/terminalrc | cut -d' ' -f 2`
NEWSIZE=$((SIZE - steps))
REGEXPR='s/FontName.*/FontName=Monospace '$NEWSIZE'/g'
sed -i "$REGEXPR" ~/.config/Terminal/terminalrc
else
echo "Usage: zi [zoom steps]";
fi;
}
z() {
if [[ ! -z $1 ]]; then
SIZE=$1;
REGEXPR='s/FontName.*/FontName=Monospace '$SIZE'/g'
sed -i "$REGEXPR" ~/.config/Terminal/terminalrc
else
echo "Usage: z [font size]"
fi;
}
@bbolker
Copy link

bbolker commented Jan 6, 2016

A slight tweak to the underlying code that allows for the font name to be something other than Monospace ... (with a fixed step of -2 in this case, but that's obviously easy to adapt)

#!/bin/bash
CONFIG=~/.config/xfce4/terminal/terminalrc
SIZE=`grep 'FontName' $CONFIG | awk '{print $NF}'`
NEWSIZE=$((SIZE - 2))
## echo "old size $SIZE, new size $NEWSIZE"
REGEXPR='s/FontName\(.*\)'$SIZE'$/FontName\1'$NEWSIZE'/g'
sed -i "$REGEXPR" $CONFIG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment