Important
For and Microsoft- and other-Reasons, this project has been migrated to Codeberg.
If you still want to support this project, consider starring it on Codeberg.
CTC is a minimal and easy-to-use calculator application for your terminal.
This project is meant for people who are quick with terminal applications, who may want a replacement for a GUI calculator.
Supported operations are the following:
- addition
- subtraction
- multiplication
- division
- factorials
- powers
- roots
- modulo
- logarithms
- nPr and nCr
- Sine, cosine and tangent
- converting to absolute numbers
- A few constants
- grouping with parentheses
- A variable for the previous answer
- A command history
- Download the binary
ctc_xyfor your architecture and OS from the latest release. - Place the file in a useful location (e.g.
~/.local/bin/ctc) - Make the file executable (e.g.
chmod +x ~/.local/bin/ctc) - Add an alias to your shells configuration file:
Bash users can add the following line to their
.bashrc:
alias ctc="~/.local/bin/ctc"Fish users can add the following to their ~/.config/fish/fish.conf file:
function ctc
~/.local/bin/ctc $argv
endThe ctc command should be available in every newly launched terminal now.
Tip
You can use any path and any alias.
~/.local/bin/ctc and ctc are just the recommended options.
Caution
MacOS and Windows binaries are included from release 0.4.0. These are not tested yet, because I don't have access to those operating systems.
The setup, especially for Windows will be different from what was said above. If you can confirm that CTC is running on Windows or MacOS, you're welcome to let me know in an issue!
Note
To compile the code yourself, clone the repository and run go build in the directory.
Run the program with help as argument or run help in continuous mode to quickly get information about operators.
The application runs with a single argument in quotes:
ctc [optional arguments] "5 * 2 // 9 + 5.4 * 10"]This command takes the second root of 9 (2 // 9), multiplies it by 5 and adds 5.4 times 10 to it.
CTC also has a continuous mode:
$ ctc [optional arguments]
> 1 + 1
2
> exitYou can navigate using the arrow keys; Up and Down are used to access the command history.
To send a command, press the Enter key.
Delete-key for deletion of the cursor's character is supported.
The mode can be exited by sending a exit, quit, :q, ;q and exit().
Every part of the calculation must be separated by a space.
The only exceptions are parentheses, which may be directly connected to a number (e.g. (2 * 5)).
To keep it simple, CTC does not support functions like n.pow() sqrt().
Instead, it has the ** (power) and // (root) operators.
The syntax is inspired by the syntax of the English language.
Therefore, 2 ** 3 means '2 to the 3' and 2 // 3 means 'the 2nd root of 3'.
Additionally, there is the % (modulo) operator, which is used like 'x mod y', and the log operator to get the logarithm of x to the base y (x log y).
Calculations like sin x or dsin x are also supported, where sin works with radians and dsin with degrees.
N.b. the same works with the cos and tan functions.
Note
Promts like cos tan xy are currently not supported.
Use cos (tan xy) instead.
The nPr (permutations) and nCr (combinations) functions work like on most calculators; for example, n nPr r (or x nPr y) would be the following:
n! / (n - r)!
All other operations are the usual ones, as used in programming languages or other calculators.
The applications works from left to right and prioritises operations in the following order:
- factorials
- roots, powers, absolute-functions, sine, cosine, etc.
- multiplication, division, nPr, nCr and modulo
- addition, subtraction and logarithms
The priorities can naturally be changed using parentheses.
The following constants are supported
- pi
- tau
- phi
- e (Euler's number)
- g (gravity)
- c (speed of light)
- h (Planck constant)
- N_A (Avogadro constant)
The negative of every constant x is available as -x.
Note
Constants g and c use SI units.
The "constant" ans can be used to insert the previous answer.
Optional arguments have to be used with the following pattern:
--argument-name=value
Supported arguments are:
Values
- comma
- dot / period / fullstop
- space
Description
Adds separators for readability (e.g. 1.000 instead of 1000)
Tip
If you are using an alias or a function to use CTC, you may add the optional arguments to it to set them as default settings.
Currently, there is no way of getting notified by the application if an update is available.
Neither is this package available for any package manager.
If you want to get notifications from GitHub, consider watching release activity for this repository.
It is also possible to enable e-mail notifications on SourceForge.
To update the program, repeat steps 1 to 3 from the installation instructions.
Please open an issue to get help and to help making this product better!
You are welcome to contribute to this project in any way. Take a look at the contribution guidelines for more information.
