Jump to content

clc - Powerful Calculator for Alfred


Recommended Posts

Alfred - CLC

This workflow adds a powerful calculator right in your Alfred bar.

 

Installing

Install insect

brew install insect
# or
npm install -g insect

Then download CLC workflow file and double click to open it with Alfred.

 

Using

clc [expression]

 

Example expressions

sqrt(1.4^2 + 1.5^2) * cos(pi/3)^2
2 min + 30 s
40 kg * 9.8 m/s^2 * 150 cm
60 mph -> m/s
6 Mbit/s * 1.5 h -> GB
# sum of the first ten squares
sum(k^2, k, 1, 10)

NOTE: Since this workflow uses insect for the calculations, please see its README for more possible types of expressions.

 

Screenshots

Screenshot 1

Screenshot 2

Screenshot 3

 

 

GitHub: https://github.com/aviaryan/alfred-clc

Download: https://github.com/aviaryan/alfred-clc/raw/master/clc.alfredworkflow

Packal: http://www.packal.org/workflow/clc

 

 

Link to comment
10 hours ago, xilopaint said:

Is not possible to bundle the workflow with insect?

The only way insect is installed is by first installing NodeJS and then installing insect globally using npm (same thing happens under the hood using homebrew). 

I don't think it would be a good idea to bundle it with the workflow. 

 

Link to comment

Not working for me:

 

[2017-09-01 02:49:16][STDERR: input.scriptfilter] /Users/xxx/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.1831759F-4FB8-40C5-B097-A5D3D126312C/run.sh:12: command not found: insect

 

Edited by xilopaint
Link to comment
8 minutes ago, xilopaint said:

Not working for me:

 

[2017-09-01 02:49:16][STDERR: input.scriptfilter] /Users/xxx/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.1831759F-4FB8-40C5-B097-A5D3D126312C/run.sh:12: command not found: insect

 

 

Please see https://github.com/aviaryan/alfred-clc/issues/1. There is a possible fix there.

I think applying it should fix your problem. I will update the workflow soon.

 

Link to comment

That seems an excessively complex solution. Can't you just use /usr/local/bin/insect?

 

FWIW, whether or not your shell can find insect isn't super helpful. Alfred doesn't use your shell's environment.

 

The best solution is to bundle the dependencies in your workflow.

 

This isn't a perfect solution with Node-based workflows, as you still have to install Node, but the workflow will at least "Just Work" for people who have Node installed without them having to install an extra bunch of stuff just for your workflow. On every Mac they have. 

 

Also, installing dependencies globally is a fundamentally bad idea, and should be avoided if possible.

Link to comment
12 minutes ago, xilopaint said:

It works, but the calculator is a bit slow. Any chance to speed up?

I think it is slow because of the multiple computations that are being sent to it while you type. I will try to do something to improve this.

 

10 minutes ago, deanishe said:

That seems an excessively complex solution. Can't you just use /usr/local/bin/insect?

I remember it didn't work out earlier for some reason (hence a lot of comments in the run.sh script). I will try it again now. 

EDIT - It didn't work with #!/bin/bash. Works with zsh.

 

10 minutes ago, deanishe said:

The best solution is to bundle the dependencies in your workflow.

 

This isn't a perfect solution with Node-based workflows, as you still have to install Node, but the workflow will at least "Just Work" for people who have Node installed without them having to install an extra bunch of stuff just for your workflow. On every Mac they have. 

If you can point me towards an example workflow, that would be awesome. ? 

Edited by aviaryan
Link to comment

I'm afraid I don't know of an example. I generally avoid Node workflows due to the inevitable external dependency on Node.

 

But npm defaults to local installations, so if you just use npm "normally", you can call your program with ./node_modules/.bin/program_name

 

Re using /usr/local/bin/insect vs changing PATH, using a full path won't work if the shebang isn't also a full path. 

 

In that case, this should be sufficient:

 

export PATH=$PATH:/usr/local/bin

Link to comment
  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...