Yes, I am a lazy typer who uses console.log() in my JS so much that I get fed up of typing it around what ever output value I need with it with for debugging.
I did have an app I wrote that I could just select the text and run a Action. But changes to the Action frameworks broke it and I never got around to fixing it ( would mean learning a whole new approach and rewriting the whole App.
So here is a tip for any others out there that uses console.log() as much as I do ( you should ) and is laaazzzy..
Create a New Automator.app Service.
Set it to Any Application
Check Output replaces selected text.
This will replace the selected text with the final output of the service.
And will preserve your clipboard ( most people would use the clipboard to transit the input and output for this type of thing)
add a shell script action.
Set the Action to as Arguments
use this code.
for f in "$@"
The code takes the input surrounds it with console.log() and outputs the result which will replace the selected text.
- Save and name the service.
Now open System Prefs.
Click the + symbol to add to the Application list on the right.
Navigate to the Applications folder and Select Hype ( and/or Whisk )
Now still in System prefs.
- Go to Keyboard -> Services
- Scroll down the list on the right until you see the name of you new service.
- Select it and give it a shortcut.
crtl +alt +cmd +c
Thats it. now when in Hype you can select your text , hold down crtl +alt +cmd and hit c
And yourFooText gets made into a console.log("yourFooText”)