How do I do my daily math on Linux ?
To do my daily math on Linux I use my terminal. Yes, on the terminal.
I use GNU/Octave in CLI mode to have a powerful calculator straight on the terminal.
The usage
The usage is very simple, I just press the keyboard shortcuts to open my terminal on Debian GNU/Linux and, after that, I type the character that will run a bash script to open my CLI GNU/Octave prompt and enter with the math expressions.
How to do this setup
The first thing you need to do is install the GNU/Octave on your Unix System.
On Debian or other Linux distributions, just use your system package manager.
For Debian-based distributions just type the command:
sudo apt install octave
At this moment, you can access the octave-cli by typing the command:
octave-cli
The result is
Note that when you access Octave this way, version, license, website, etc. information is displayed. A standard prompt is offered too.
To hide the help information, you need to type the following command:
octave-cli -q
Use -q to a quiet enter.
Recommended by LinkedIn
To change the prompt we need to evaluate a built-in function.
octave-cli -q --persist --eval "PS1('>> ')"
Let's write a bash script to automate all these steps
Open a text editor and write the following instructions:
#!/bin/bash
a="system('clear')"
b="PS1('>> ')"
octave-cli -q --persist --eval "$a;$b;clc"
Save this file into a known folder with the wanted name for your calculator. Example:
/home/'username'/bash/calc -here we save the file with the calc name into the [bash] directory.
After saving the file, set the file permissions as an executable file.
chmod +x calc
The ultimate step is to define the [bash] directory as an environment directory.
Into the hidden system files .bashrc or .bash_aliases in your home directory, include the following instructions:
export PATH=~/bash:$PATH
Now, just open your terminal, type 'calc', and enjoy it.