From 8e8cdc0502fc35844975548fa268e7ed027d00b7 Mon Sep 17 00:00:00 2001 From: Cooper Maruyama Date: Fri, 1 May 2015 01:34:20 -0700 Subject: [PATCH 1/4] Add coffeescript aliases: cf, cfc, cfp cf: compile and show output cfc: compile & copy cfp: compile from pasteboard & print --- plugins/coffee/coffee.plugin.zsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 plugins/coffee/coffee.plugin.zsh diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh new file mode 100644 index 00000000..96393f66 --- /dev/null +++ b/plugins/coffee/coffee.plugin.zsh @@ -0,0 +1,13 @@ +#!/bin/zsh + +# compile a string of coffeescript and print to output +cf () { + coffee -peb $1 +} +# compile & copy to clipboard +cfc () { + cf $1 | tail -n +2 | pbcopy +} + +# compile from pasteboard & print +alias cfp='coffeeMe "$(pbpaste)"' From a315ddc075e6a6a4b9dbdcaced0fa08349597223 Mon Sep 17 00:00:00 2001 From: Cooper Maruyama Date: Fri, 1 May 2015 01:37:55 -0700 Subject: [PATCH 2/4] typofix --- plugins/coffee/coffee.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh index 96393f66..be34b03c 100644 --- a/plugins/coffee/coffee.plugin.zsh +++ b/plugins/coffee/coffee.plugin.zsh @@ -6,7 +6,7 @@ cf () { } # compile & copy to clipboard cfc () { - cf $1 | tail -n +2 | pbcopy + cf $1 | pbcopy } # compile from pasteboard & print From 24552f02259829428c412a88729de4cfd0b7ba8b Mon Sep 17 00:00:00 2001 From: Cooper Maruyama Date: Sat, 2 May 2015 07:14:21 -0700 Subject: [PATCH 3/4] Add readme and add new alias cfpc: paste+compile+copy --- plugins/coffee/README | 31 +++++++++++++++++++++++++++++++ plugins/coffee/coffee.plugin.zsh | 3 +++ 2 files changed, 34 insertions(+) create mode 100644 plugins/coffee/README diff --git a/plugins/coffee/README b/plugins/coffee/README new file mode 100644 index 00000000..d0e7bbe7 --- /dev/null +++ b/plugins/coffee/README @@ -0,0 +1,31 @@ +## Coffeescript Plugin + +This plugin provides aliases for quickly compiling and previewing your +cofeescript code. + +When writing Coffeescript it's very common to want to preview the output of a +certain snippet of code, either because you want to test the output or because +you'd like to execute it in a browser console which doesn't accept Coffeescript. + +Preview the compiled result of your coffeescript with `cf "code"` as per the +following: + +```zsh +$ cf 'if a then be else c' +if (a) { + b; +} else { + c; +} +``` + +Also provides the following aliases: + +* **cfc:** Copies the compiled JS to your clipboard. Very useful when you want + to run the code in a JS console. + +* **cfp:** Compiles from your currently copied clipboard. Useful when you want + to compile large/multi-line snippets + +* **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the + the result back to clipboard. diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh index be34b03c..1a7bedd8 100644 --- a/plugins/coffee/coffee.plugin.zsh +++ b/plugins/coffee/coffee.plugin.zsh @@ -11,3 +11,6 @@ cfc () { # compile from pasteboard & print alias cfp='coffeeMe "$(pbpaste)"' + +# compile from pasteboard and copy to clipboard +alias cfpc='cfp | pbcopy' From d80918bf981d5df3f192346b44c0c35636ee7b2b Mon Sep 17 00:00:00 2001 From: Cooper Maruyama Date: Sat, 2 May 2015 07:16:27 -0700 Subject: [PATCH 4/4] add markdown extension to README --- plugins/coffee/{README => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/coffee/{README => README.md} (100%) diff --git a/plugins/coffee/README b/plugins/coffee/README.md similarity index 100% rename from plugins/coffee/README rename to plugins/coffee/README.md