Live data from Hacker News

Quick tip for developers who use OS X

news.ycombinator.com

381–390 of 406 posts

Re: Quick tip for developers who use OS X

#381
post #343

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 /pa…

thank you!

happy to help!

Re: Quick tip for developers who use OS X

#382
post #72

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).

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?

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.

Re: Quick tip for developers who use OS X

#383

drag + drop files to terminal to get its location. I often do "cd " + dragon drop folder to get to that folder in terminal

I'm a bit late, but it's useful to know that while dragging, keystrokes are handled normally. Using the parent comment's operation as an example, you can start dragging a folder in the Finder, then Command-Tab to the terminal (or hover over the Dock icon and then hover over the proxy window), Command-` to a particular terminal window, or Command-N to open a new one, and then type "cd " before finally dropping the file. ("cd " is nicely left-handed for those using the right hand for the pointing device.)

Re: Quick tip for developers who use OS X

#384
post #105

Earlier quoted context omitted.

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?

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.

Just because that's the only problem you use it to solve doesn't mean that's the only problem it solves.

Re: Quick tip for developers who use OS X

#385
As it wasn't mentioned yet: pushd / popd

These two commands replace 'cd' and work with a directory stack of different paths.

   $ pushd tmp   # cd to tmp and remember current path /
   /tmp /
   $ pwd
   /tmp
   $ cd /usr   # normal cd to wherever you want...
   $ pwd
   /usr
   $ popd   # pop the stck and get back to the previous path
   /
   $ pwd
   /
Subsequent pushd will stack multiple paths.

It's a built-in of bash and other shells. It works even with Windows' cmd.exe

Re: Quick tip for developers who use OS X

#387

Another really useful command is the open $ open filename.png $ open . $ open -e filename.txt $ open -a Pixen filename.png The first command will open the file with the default application. Open . will open the current directory in finder, which I find very helpful. The -e flag will open the file in textedit. The -a will open the file in the given application name.

open -n is also useful: Allows you to run two instances of the same app at a time.

Thank you for this! It always frustrated me that I couldn't open multiple videos at once in VLC.

Re: Quick tip for developers who use OS X

#388

Earlier quoted context omitted.

"Paste and match formatting" shouldn't be necessary for most programs, and isn't a platform standard. Paste is command-V. A sensible application should do the most likely thing the user wants with paste and overload the shortcut for weird stuff. The fact that Microsoft consistently does the weird thing by default isn't a platform problem with the Mac, just with Word. Now you could point out Pages has the same shortcu…

"Paste and match formatting" shouldn't be necessary for most programs, and isn't a platform standard. Yes, it is. https://developer.apple.com/library/mac/documentation/UserEx... says "Table A-2 lists the system-reserved and commonly used keyboard shortcuts mentioned in the rest of this document." Table A-2: contains ../art/ks_option_2x.png ../art/ks_shift_2x.png ../art/ks_command_2x.png V Apply the style of the surro…

OK I didn't know Apple had made that a standard -- so I agree with the GP that it's dumb. If I can't easily type a shortcut with one hand, it shouldn't be a standard shortcut.

I'm suggesting the standard paste should behave as expected, not adhere to some literal definition the user doesn't care about. If I copy a passage of text from one document and paste it into another, I generally want it to look like it belongs in the destination document but I don't want to lose obvious intentional styling such as italicization.

The common case should be the easy case. Instead we have the common case and the four-fingered shortcut both doing the wrong thing. Awesome.

Re: Quick tip for developers who use OS X

#389
post #213

Earlier quoted context omitted.

Also very useful for similar use cases is qlmanage. $ qlmanage -p

This seems to run whatever code usually runs when you hit [space] on a filename in a Finder window. (Except that it outputs a bunch of debugging information.) Under what circumstances is that any better or more useful than "open"?

You can hide the debugging info by redirecting the output streams.

    $ qlmanage -p  &>/dev/null

Re: Quick tip for developers who use OS X

#390

The first thing I do when setting up a new Mac is make the Caps Lock key into another Control key. System Preferences > Keyboard > Modifier Keys Saves lots of awkward pinky-bending.

Is it me or do Mac Caps Lock keys require you to hold them down for close to a second for them to activate? There appears to be some kind of hardware timer in them to work...? I noticed this coming from Windows and Linux on other keyboards where tapping Caps Lock works but on Mac OSX with an Apple keyboard or on a Macbook you have to make a real deliberate effort to keep the key down longer than a nanosecond for it t…

I noticed this on the lock screen. Often you'd have to tap multiple times on caps lock before it even turns on. I assume it's to prevent accidental caps locking, but it can be rather irritating
Post reply on HN