Live data from Hacker News

Quick tip for developers who use OS X

news.ycombinator.com

251–260 of 406 posts

Re: Quick tip for developers who use OS X

#251
Off-topic, but related: does anyone know a way to bind a key, and F-key for example, to a particular application in OSX? The behavior I'm looking for is almost achievable with Spaces - but it's basically when you hit the combo from anywhere, the target application comes to the foreground, or if it's not running, it launches.

Command-Tab is fine and dandy, but I want more stability in my application switching. And if it doesn't exist, I may have to dust off XCode like I've been threatening to do for a while now.

Re: Quick tip for developers who use OS X

#252

Earlier quoted context omitted.

> Sorry, but this is laughable. Keyboard shortcuts are far more useful and consistent across applications in OS X. I don't agree with this at all. I find it baffling that a company of great designers made such bad decisions about keyboard shortcuts. Perhaps they are consistent, but they are consistently bad. Paste and match style (incredibly useful) is "alt-shift-command-v" i.e. four keys. There are plenty of other s…

"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 surrounding text to the inserted object (equivalent to the Paste and Match Style command). See “The Edit Menu.” That links to https://developer.apple.com/library/mac/documentation/UserEx..., which describes the command, too.

I disagree with the claim that this is a bad choice, though. It may not be optimal if starting from a tabula rasa, but Apple did not do that when it introduced the combination, five years ago or so, in my memory. By that time Command-V has done styled paste for about 25 years, making it difficult to dethrone.

We must be glad that we have a standard for this, not angry that it may be a bit complex to type.

Re: Quick tip for developers who use OS X

#253
post #244
post #52

Bash, running in your terminal, understands both the Emacs and the Vi commands. By default is Emacs, so you can C-a (control-a) for beginning of line, C-p to go back in command line history, or C-r to search it. I prefer the Vi mode, though. Add to your .bashrc set -o vi Then you can press escape to go from input mode to normal mode; there k will take you to the previous line in command line history, j to the next li…

I use these settings in my .inputrc. The get me a few more commands and even the ability to escape using jj. set completion-ignore-case On set bell-style none set editing-mode vi $if mode=vi set keymap vi-command "gg": beginning-of-history "G": end-of-history set keymap vi-insert "jj": vi-movement-mode "\C-p": history-search-backward

Thanks for this. I switched my input mode to VI and was greatly missing using Ctrl-L to clear the screen when in input mode. I hadn't known about the inputrc before. Adding this line below your "\C-p" line fixed that for me:

    "\C-l": clear-screen

Re: Quick tip for developers who use OS X

#255
So I see a lot of comments in this thread about OSX has a much cleaner interpretation of Command-C vs Ctrl-C in Linux. Actually, the problem is that you should NOT be using ctrl-c to copy in linux. the global copy command in Linux obeys the CUA [1] standard. Copy is defined to be "Ctrl-Insert" and paste is defined as "Shift-Insert". This will work on all kinds of user interfaces on Linux - including the cmdline, the browser, etc.

However this is an issue which I dont know is a bug or something (I'm on Ubuntu 12.04) - if you open "System Settings" in Ubuntu and copy text from there, I'm not able to paste it on the browser, but am able to paste it everywhere else using the command sequence described above.

[1] http://en.wikipedia.org/wiki/IBM_Common_User_Access

Re: Quick tip for developers who use OS X

#256

Earlier quoted context omitted.

> Sorry, but this is laughable. Keyboard shortcuts are far more useful and consistent across applications in OS X. I don't agree with this at all. I find it baffling that a company of great designers made such bad decisions about keyboard shortcuts. Perhaps they are consistent, but they are consistently bad. Paste and match style (incredibly useful) is "alt-shift-command-v" i.e. four keys. There are plenty of other s…

"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…

This isnt just about copying Word. Mac Mail has the same paste with formatting behavior. As does Evernote for that matter.

Re: Quick tip for developers who use OS X

#257
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"?

Correct (man 1 qlmanage). Depending on the type of file, it is usually faster to open quicklook than opening the file in its default application, especially if you just want to take a look and you don’t actually need to edit the file.

Re: Quick tip for developers who use OS X

#258
post #180
post #28

Useful when copy/pasting things to share with other people in email and such: $ pbpaste | pbcopy takes the current contents of the copy/paste buffer and removes color/font/background color rich formatting and puts just plain text back into the paste buffer. And of course pbcopy and pbpaste are also very useful on their own.

Quite a lot of OS X applications support pasting with matching style (Cmd+Shift+V), which does exactly the same thing.

Actually, natch's trick does just the opposite. It strips out any formatting information that may accompany the text on the clipboard.

I've used the same trick on occasion when copying text from web pages into Gmail. When you paste such text into a Gmail draft, Gmail tries to duplicate the format of the original, which is often not what you want. pbpaste | pbcopy solves the problem nicely.

Edit: But Shift-Option-Cmd-V is easier. Thanks, Janteh!

Re: Quick tip for developers who use OS X

#259
post #46

Earlier quoted context omitted.

... so do they prefer a track ball or TrackPoint (or some sort of Minority Report gestures-based system)? /s

No, they just use the keyboard. And use a mouse emulator (move pointer with the keyboard) on those instances where there's no kb shortcuts.

False, they use tput to move the cursor.

http://www.bashguru.com/2010/04/how-to-handle-cursor-movemen...

Re: Quick tip for developers who use OS X

#260

Earlier quoted context omitted.

More: - C-u to kill (cut) from current location to beginning of the line - C-k to kill (cut) from current location to end of line - C-w to kill (cut) from current location to beginning of word - C-y to paste (copied / cut) lines - C-l to clear screen (I use the shit out of this) - Ctrl + shift + '-' (holding ctrl, shift, minus at the same time), for undo. That is it. EDIT: Damn it, I didn't realize I was saying a bun…

Also, most emacs keybindings (C-u and C-w don't, but C-k, e, a and y do, at the very least) work in all Cocoa text fields. This (in general) means you have two copy buffers: the normal, system wide Cmd-C (or X), Cmd-V and the "Cocoa wide" C-k C-y buffer

The basic emacs shortcuts even work on iOS, if you're using a Bluetooth keyboard. Now the muscle memory works everywhere.
Post reply on HN