Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a line in a file, which I have open in TextMate. I would like to select the line, or rather the content of the line; 54 + 34.43 and have it be replaced with the total sum.

I've used the "Filter Through Command" dialog which gives me access to CLI tools. I figure this would also be useful here, but I cannot simply pass off the equation to bc.

Any pointers? Perhaps via python? I'd like to be able to use Filter Through Command and avoid taking on some sort of Bundle to accomplish this.

share|improve this question
    
Several scripting bundles support evaluate current line or something similar. –  Daniel Beck Sep 14 '11 at 8:08
add comment

1 Answer

up vote 1 down vote accepted

There's a "Math" bundle, I think it's active by default.

With your expression selected hit CtrlShiftc to open a contextual menu with a bunch of number-related operations.

--EDIT 1--

I didn't read your question correctly. Here is a page which helped me a lot while looking for a quick way to do some math on the CLI.

In short, write a very short shell script wrapped around bc, make it executable, put it in your path and call it via TextMate's Filter Through Command.

--EDIT 2--

While a shell script might be more portable and reusable and the "Math" bundle might be a little more versatile the ad hoc command you need is echo "$TM_SELECTED_TEXT" | bc. It will be remembered by TextMate and shown as default command next time you hit CmdAltr.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.