https://github.com/arzzen/calc.plugin.zsh
zsh calculator - with support for basic math
https://github.com/arzzen/calc.plugin.zsh
bash calc calculator ohmyzsh-plugin plugin shell zsh zsh-calculator
Last synced: 19 days ago
JSON representation
zsh calculator - with support for basic math
- Host: GitHub
- URL: https://github.com/arzzen/calc.plugin.zsh
- Owner: arzzen
- License: gpl-2.0
- Created: 2015-05-20T20:20:45.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-07-25T06:53:47.000Z (12 months ago)
- Last Synced: 2025-04-02T02:38:02.202Z (3 months ago)
- Topics: bash, calc, calculator, ohmyzsh-plugin, plugin, shell, zsh, zsh-calculator
- Language: Shell
- Homepage: https://lukasmestan.com/simple-zsh-calculator/
- Size: 19.5 KB
- Stars: 132
- Watchers: 4
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Simple zsh calculator
> This is a calculator which runs on zsh.### Demo

### Installation
1. Clone this repository to your favorite path (e.g. `~/.oh-my-zsh/plugins/calc/calc.plugin.zsh`)
2. `source` the file in your `.zshrc`
3. Restart your `zsh````sh
# Your .zshrc
source $HOME/.oh-my-zsh/plugins/calc/calc.plugin.zsh
```#### Via [antigen](http://antigen.sharats.me/)
Add to `.zshrc`
```sh
antigen bundle arzzen/calc.plugin.zsh
```#### Via [zplug](https://github.com/zplug/zplug)
Add to `.zshrc`
```sh
zplug "arzzen/calc.plugin.zsh"
```### Usage
```bash
# addition
root@pc:~$ = 5+3
8# multiplication
root@pc:~$ = '4*2'
8# subtraction
root@pc:~$ = -4-2
-6# division
root@pc:~$ = 5.0/2
2.5# square root
root@pc:~$ = sqrt(2)
1.41421# parentheses
root@pc:~$ = "(6+6)*6"
72# convert from decimal to hexadecimal
root@pc:~$ = "[#16] 255"
16#FF# convert from decimal to binary
root@pc:~$ = "[#2] 12"
2#1100# convert from binary to decimal
root@pc:~$ = "2#1100"
12# convert from hexadecimal to decimal
root@pc:~$ = "16#FF"
255# arctangent
root@pc:~$ = atan(1)
.785398# PI value
root@pc:~$ = PI
3.14159# more complex
root@pc:~$ = "3.4+7/8-(5.94*(4*atan(1)))"
-15.2611
```### Alternative Implementations
```
# Put these in your .zshrc (No need to install a plugin)
cc() python3 -c "from math import *; print($*);"
alias cc='noglob cc'
# You can use `cc` just like `=` from above. All functions from the math module of Python are available for use.
```### Plugin location
```bash
.oh-my-zsh
└─── plugins/
└─── calc/
└─── calc.plugin.zsh
```