The best calculator shortcut in Ubuntu
I only use python as a calculator. However a friend made me remark that it’s
faster to hit the “Calc” key from your keyboard and use the default
gnome-calculator
. Although I don’t quite agree since I always have a
terminal opened, I still decided to make some good use of this otherwise
superfluous “Calc” key.
The best calculator:
I mapped a new shortcut to it. That’s my calculator now:
gnome-terminal --hide-menubar --geometry=60x20 -t Python -x python -Q new -i -c "from numpy import *"
A quick explanation:
It launches a new terminal (gnome-terminal
) executing the command python -Q new -i -c "from
numpy import *"
.
The gnome-terminal part:
--hide-menubar
disables the menu bar of the terminal (file, edit and so on)--geometry=60x20
: terminal size of 60 columns x 20 lines-t Python
: title of the windows is “Python”-x
: everything after this is the command executed.
The python part:
-Q new
allow int/int divisions to return float values (no longer required to write points after numbers to make sure they are floats).-c ...
execute the specified command.-i
open the interactive shell after having executed the command.
Like this, I already have all numpy loaded, and I can type pi
, e
, log
and
all those functions quite suited for a calculator.
All of this was just because I like to be the one that’s right.
The best calculator (bis):
I improved the previous solution by setting a specific gnome-terminal profile for this task. It’s cooler because I can set a different font (Inconsolata), a more transparent background, and write the geometry, the window title and the python command directly in the profile settings. This new profile is named “Calculaterm”, so I updated my keyboard shortcut to simply this:
gnome-terminal --hide-menubar --window-with-profile=Calculaterm