6 ms·
Show HN: Copy any code to clipboard in OS X, adding proper syntax highlighting
- hellbanner 11y agoAlso useful: Access over a hundred previous clipboard copies & cuts with a shortcut: http://www.clipmenu.com/ http://www.clipmenu.com/
- blacksmith_tb 11y agoClipMenu is great, but basically abandonware these days. There was a small flurry of activity when its github repo went up, but then silence: https://github.com/naotaka/ClipMenu https://github.com/naotaka/ClipMenu
- hellbanner 11y agoWell, it still works.
- srikz 11y agoFlycut[1] is a Mac-only alternative with similar functionality. [1]: https://github.com/TermiT/Flycut https://github.com/TermiT/Flycut
- racl101 11y agoThat's pretty friggin' rad yo! Especially the properly indented code.
- deleted 11y ago[deleted]
- nathancahill 11y agoAs I understand, it automatically resubmits if the post was interesting but didn't get enough attention. Sounds like it literally is being resubmitted instead of just getting boosted.
- scoot 11y agoIf it was just boosted, then presumably 'temporal gravity' (or whatever that's called here) would pull it back down again.
- pducks32 11y agoThis is soo useful!
- Albright 11y agoIncidentally, Panic's Coda [1] can do something like this as well in a slightly-more-roundabout way: paste code into it (or just write it), let Coda highlight it, then do Edit > Copy with Styles. I use this to style code I then paste code into presentation slides in order to include pretty code samples on a slide without resorting to screenshots; it has infinite resolution, and someone can copy it from the presentation file or PDF later. I presume this tool would be great for similar uses. 1: https://panic.com/coda https://panic.com/coda
- ben174 11y agoZip files in the repo? Looks odd to me.
- minimaxir 11y agoGit and the Service files do not play well, so I have to Zip the files first.
- curun1r 11y agoThere are two XML files and a PNG file in the one zip I looked into...why doesn't that work with git? Incidentally, there's also a bunch of extra Dropbox files that you probably don't want to be including. It looks like you developed this on a Mac, saved it to Dropbox and then created the Zip on a Windows box. Sorry to say it, but the whole thing feels like an amateurish wrapper around: pbpaste | /usr/local/bin/pygmentize -g -O style=... -f rtf -l ... | pbcopy which appears to do all the work.
- minimaxir 11y agoSince the services are not a single file, it is not user-friendly to download directly from the Repo if the files are not zipped. The tool is essentially a wrapper. I do not deny that in the credits. However, there's nothing wrong with that. It's simple, yes, but it does what it promises. (Additionally, it still took a couple hours in QA and README presentation) There shouldn't be Dropbox metadata though. I'll double-check that.
- curun1r 11y ago> Since the services are not a single file, it is not user-friendly to download directly from the Repo if the files are not zipped. I think you're conflating two separate things, source code and a packaged releases. The Github repository should have the source code, which in your case is the XML code for the workflow and plist. You then create a release [1] from that software. It's usually customary to include the script used to build it, which in this case is likely just a shell script wrapper around the zip command to create the archive. The important point is that the source is always visible. Uploading zip files into the repo gives the impression that you're trying to hide something, even if that isn't the case. Also, one of the great things about open source is that people can be curious. It's likely that if you had checked in the unzipped files, people would have browsed through them in the Github UI to see how it worked. Fewer people will take the time to clone the repo or download/unzip/browse the zip file. [1] https://github.com/blog/1547-release-your-software https://github.com/blog/1547-release-your-software
- igorgue 11y agoI used "Save As HTML" on MacVim for this before, well welcomed!
- twerkmonsta 11y agoOff-topic, but what is that application in the `deep4me.png` screenshot?
- radnor 11y agoIt's Pixelmator - http://www.pixelmator.com/ http://www.pixelmator.com/
- Albright 11y agoPixelmator [1], a more affordable Photoshop clone. (I personally prefer Acorn [2].) 1: http://www.pixelmator.com/mac/ http://www.pixelmator.com/mac/ 2: http://flyingmeat.com/acorn/ http://flyingmeat.com/acorn/
- pavel_lishin 11y agoI paid for Pixelmator after deciding to no longer pirate Photoshop; what makes you prefer Acorn?
- Albright 11y agoI think the UI is cleaner and more Mac-like; Pixelmator felt a little too comfortable throwing consistency and OS X UI standards out the window. It's been a while since I tried Pixelmator, though, so maybe this comparison is no longer fair. Also, though it probably won't matter for most people, Acorn's file format is pretty ingenious: http://shapeof.com/archives/2013/4/we_need_a_standard_layered_image_format.html http://shapeof.com/archives/2013/4/we_need_a_standard_layere...
- TazeTSchnitzel 11y agoIf only I'd known of this two months ago, when making slides in PowerPoint for a talk. I ended up doing manual syntax highlighting! –——— Somewhat relatedly, it's sometimes annoying how OS X love preserving styles when copying text. I may be misremembering, but I think text copied from Terminal.app uses your terminal font.
- Camillo 11y agoUse command-option-shift-V to paste without styles.
- TazeTSchnitzel 11y agoWhat applications does this work in? It doesn't work in TextEdit, for instance.
- Camillo 11y agoYes it does.
- arm 11y agoYes, it works in TextEdit. It works in any application that has the Edit > Paste and Match Style ⌥⇧⌘V menu item. This command matches whatever style you’re currently using in the application you select this menu item, completely ignoring the original style of the text on the pasteboard. In effect, it basically is 'pasting without styles'.
- TazeTSchnitzel 11y agoOh right, it didn't work for me because OS X inexplicably breaks my left Alt key once my system has been running for long enough. Never mind.
- arm 11y agoWait, seriously? That sounds horrible. :( What version of OS X are you using? Are you using an Mac-oriented keyboard (ctrl/option/command) or a Windows-oriented keyboard (ctrl/windows/alt)? Also keep in mind, if you haven’t already tested it out on multiple computers, it could be the keyboard itself that’s dying. (I’ve never experienced the issue. I actually do use a Windows-based keyboard on my Mac, but I use it with ControllerMate¹ (swapped the Windows key and alt key and changed the functions of all the nonstandard keys (multimedia keys, zooming in and out keys, Windows Flip 3D key, etc.)). ―――――― ¹ — http://www.orderedbytes.com/controllermate/ http://www.orderedbytes.com/controllermate/
- Camillo 11y agoNice, but why not have an "add syntax coloring" service instead?
- minimaxir 11y agoThat would only be useful if you are typing code directly into the productivity application, which is a relatively rare occurrence compared to copying it from an IDE.
- Camillo 11y agoNo, you could copy and paste it, and then add highlighting after it's pasted. I guess one advantage of using a single command is that you can select, right-click the selection and run the service, and then paste. OTOH, I would probably end up doing a normal copy with command-C, pasting with command-V, and then having to do it again because I forgot to do the special copy. OTOH, if you're going to have a combination command, it seems that it's more common to have special behavior in the paste operation rather than in the copy one. See "Paste and Match Styles", "Paste Special" etc. No big deal in any case, I was just wondering what the rationale was behind the UI choice.
- danso 11y agoBrilliant on so many levels, thank you for this...I can't count the number of times I've tried to explain a snippet of code via GMail...it's already painful enough to highlight the text and convert it to monospace (which an annoying number of people fail to do)...nevermind also producing human-readable colors. I actually think I'll stick to the command-line/pipeable script you link to...for teaching purposes, I've wanted to make myself a utility that converts syntax-higlighted code into a PNG...so that I can show the code but make it much more difficult to just copy/paste. edit: And of course, the thing that I want, someone has already made and yet I couldn't even bother to RTFM. From running `highlight --h` at the command line: SVG output options: --height set image height (units allowed) --width set image width (see --height)
- Retra 11y agoI really don't see why you'd want PNGs of text. I get that you don't want people to copy, but it is readable text. Don't show people code if you don't want them to have the exact same code. And anyone willing to copy/paste has already committed to wasting their time. Also, this kind of thing already exists: http://www.free-ocr.com/ http://www.free-ocr.com/
- z1mm32m4n 11y agoI'd guess maybe educational purposes? Forcing people to write the code line by line can have instructive value.
- danso 11y agoThis is for teaching code. I want people to see my code, but I want to remove as many of the conveniences that enable them to just copy-paste that I can -- while not severely hindering my own ability to write and maintain lessons (once code is in PNG...it's quite difficult to grep and/or re-edit), because I believe having to just physically type out code slows you enough that you actually think about the code. Also, having to type out code pretty much forces you to get into the habit of using keyboard shortcuts, particularly auto-complete.
- zZorgz 11y agoJust to note: if the copy action brings up a dialog requesting what language to pick, then the menu item's name should end with an ellipsis character, as according to Apple's UI guidelines.
- arm 11y agoYep. Apple mentions it here¹, as well as the reason: “Be sure to create the ellipsis character using the key combination Option-; (Option-semicolon). This ensures that an assistive app can provide the correct interpretation of the character to a disabled user. If you use three period characters to simulate an ellipsis, many assistive apps will be unable to make sense of them. Also, three period characters and an ellipsis don't look the same because the periods are spaced differently than the points of an ellipsis.” Of course, Apple’s advice for typing U+2026 HORIZONTAL ELLIPSIS (…) (typing ⌥;) is only accurate if you’re using a US keyboard layout. The key combination will be different in other keyboard layouts. For example, in the 'Canadian French - CSA' keyboard layout, typing ⌥; will give you U+00B0 DEGREE SIGN instead (which makes sense if you actually look at a French ISO layout keyboard, like this² one or this³ one). On that keyboard layout, to get U+2026 HORIZONTAL ELLIPSIS, you’d actually type ⌥⇧L (option-shift-L). ¹ — https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/TerminologyWording.html#//apple_ref/doc/uid/20000957-CH15-SW3 https://developer.apple.com/library/mac/documentation/UserEx... ² — http://f.cl.ly/items/42233R3c2e0z2e2i3V2f/MB110C.tiff http://f.cl.ly/items/42233R3c2e0z2e2i3V2f/MB110C.tiff ³ — http://f.cl.ly/items/1q2N2t3N0Z3z2u3c2P3h/MLA22C.tiff http://f.cl.ly/items/1q2N2t3N0Z3z2u3c2P3h/MLA22C.tiff
- arm 11y agoHah, this is interesting. MacHeist just added PopChar X to their bundle¹, so I tried it out, and I was surprised to find it actually shows the keyboard shortcut for your selected character (if any exists) based on your current keyboard layout². That’s pretty convenient. ―――――― ¹ — https://macheist.com/bundle https://macheist.com/bundle ² — http://f.cl.ly/items/0p330J1Y3K2v0N1t2M2p/popchar_shortcut.png http://f.cl.ly/items/0p330J1Y3K2v0N1t2M2p/popchar_shortcut.p...
- mholubowski 11y agoHi! I love this and will share it loud and proud. Could you please let me know how you created the second gif in the the README? - Mike
- minimaxir 11y agoThe second GIF is just Keynote animations, and exporting as a video. Then converting the Video to GIF.