Skip to content
zsh calculator - with support for basic math
Branch: master
Clone or download
arzzen Merge pull request #5 from Matows/patch-1
Add zplug install section
Latest commit 6aa46a8 Nov 29, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Sep 6, 2017
CONTRIBUTING.md Create CONTRIBUTING.md Sep 11, 2017
LICENSE
README.md Add zplug install section Nov 28, 2018
calc.plugin.zsh

README.md

Simple zsh calculator

This is a calculator which runs on zsh.

Demo

calc 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
# Your .zshrc
source $HOME/.oh-my-zsh/plugins/calc/calc.plugin.zsh

Via antigen

Add to .zshrc

antigen bundle arzzen/calc.plugin.zsh

Via zplug

Add to .zshrc

zplug "arzzen/calc.plugin.zsh"

Usage

# 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

Plugin location

.oh-my-zsh
└─── plugins/
     └─── calc/
          └─── calc.plugin.zsh
You can’t perform that action at this time.