Lurker News
OSX Terminal: hold option and click a position in the current line to move your cursor to that position. #yearslost

Comments (395) 107 threads

Earlier comments
ancarda6 replies#
Nobody seems to have posted this yet:

    python -m SimpleHTTPServer
I'd recommend an alias like "serve". It basically puts the current directory online (binds to 0.0.0.0:8000).
verandaguy5 replies#
Am I wrong to have long dismissed this as little more than an easter egg, or, at best, a toy server to test basic webpage functionality?
ramses01 reply#
Yes. It's like a ghetto SCP for giving files to people on windows who don't have SCP. You can use it for basic web functionality, you can use it (carefully) as a mechanism for testing or serving test results. I wouldn't keep it running for days, but it's an amazingly useful tool.
verandaguy#
Whoa, never thought of it that way. The makeshift SCP is really a good idea!
ancarda1 reply#
I use it quite a lot to move files between my computers, stream content to my phone, test out web designs. I suppose it's like net cat, it's useful for some. I think "toy server" is fairly accurate, I can't see anyone using this in production but I can't see people installing nginx on their laptops either.
kalleboo#
> I can't see people installing nginx on their laptops either.

OS X comes with apache preinstalled though

thom1 reply#
The only problem it really solves is if you've got non-relative paths in your HTML/CSS. I've used this a couple of times in those situations.
School-Cotton1 reply#
Just because that's the only problem you use it to solve doesn't mean that's the only problem it solves.

Continue this thread — 1 reply

tantaman#
Depends on what you're developing. If you're doing single page apps that get their data from an external service then this is incredibly useful.
School-Cotton#
Our build process automatically generates a directory tree of HTML-formatted unit test coverage reports. Sometimes it's nice to be able to share links to those reports in a code review. I use python SimpleHTTPServer for that.
MrBuddyCasino#
Related:

  python -m smtpd -n -c DebuggingServer localhost:25
A makeshift SMTP server that logs all messages to the console.
skyebook#
Mind blown. Thanks!
stock_toaster1 reply#
similarly, you can get a janky json pretty printer by doing:

   curl -s http://some/json/url | python -m json.tool
wging#
When your needs stretch beyond that, try 'jq'. http://stedolan.github.io/jq/

For pretty-printing without modification,

    cat myjson | jq '.'
p8952#
Or for Python3: python -m http.server .

Or Ruby: ruby -run -e httpd .

petercooper5 replies#
A new one for me I accidentally found the other day..

If you use Spotlight to find something and then want to see the file in Finder, Cmd+click the item in the Spotlight dropdown.
Edited from Cmd+shift+click due to note in child comment :-)

yuxt3 replies#
isn't it just Cmd+click ?
petercooper#
Oh hey, so it is, even better! :)
samelawrence#
yes.
NatW#
In Mavricks (only one I can be sure of) when you hover over spotlight results and hold Cmd, you get a (quite nice) file preview/info.
panzi#
Under Konsole/Yakuake (KDE) its: Contextmenu -> Open Link
pygy_#
You can also use Cmd + Return.
bluthru#
Cmd + R is universally "Reveal in Finder".
xixixao#
First thing I install on a Mac is Alfred. Check it out. `space` followed by name searches directories and files.
roberthahn1 reply#
oo! As long as we're sharing our favourite terminal tips, here's mine: In your .bash_profile, add this line:

alias imgsz='sips -g pixelWidth -g pixelHeight'
sips stands for "scriptable image processing system"[1], and provides terminal users with a toolset for inspecting and manipulating images. The alias above is really useful for web developers who need a quick look at how big a given image is:

    $ imgsz logo.png
    /path/to/logo.png
    pixelWidth: 500
    pixelHeight: 120
[1] https://developer.apple.com/library/mac/documentation/Darwin...
aroman1 reply#
thank you!
roberthahn#
happy to help!
drcongo2 replies#
Lovely, thanks. Also, is it common knowledge that CMD+click on a URL opens that URL in your default browser? Useful for the "Running on messages.
benwoodward#
Nice tip, thanks. However, it only works with double-click for me.
rsynnott#
That's in iTerm, I think. In Terminal.app, it's CMD+double-click.

Load more comments