mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS
https://mths.be/dotfiles
MIT License
30.35k stars 8.73k forks source link

More .osx suggestions? #5

Open mathiasbynens opened 13 years ago

mathiasbynens commented 13 years ago

http://superuser.com/questions/11026/textmate-creates-temporary-files-and-doesnt-delete-them

defaults write com.macromates.textmate OakDocumentDisableFSMetaData 1
KOENVANRHEE commented 13 years ago

Great work! Lovin' it.

Maybe not .osx but a suggestion:

quit () {
        for app in $*; do
                osascript -e 'quit app "'$app'"'
        done
}

and

pman() { man -t "${1}" | open -f -a Preview; }
ghost commented 13 years ago

Hidden

defaults write -g NSSavePanelStandardDesktopShortcutOnly -bool true # cmd-D, not cmd-delete (10.7)
defaults write -g WebAutomaticDashSubstitutionEnabled -bool false
defaults write -g WebAutomaticTextReplacementEnabled -bool false
defaults write -g WebContinuousSpellCheckingEnabled -bool false
defaults write com.apple.CrashReporter DialogType none
defaults write com.apple.Safari NSQuitAlwaysKeepsWindows -bool true #* enable Resume per application
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
defaults write com.apple.dashboard mcx-disabled -bool true # disable Dashboard
defaults write com.apple.helpviewer NormalWindow -bool true # not always on top
defaults write com.apple.iTunes hide-ping-dropdown -bool true #* oblong buttons that appear on song lists
defaults write com.apple.spotlight DictionaryLookupEnabled -bool false # disable Dictionary results
# Already included in .osx
defaults write com.apple.finder QuitMenuItem -bool true
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.frameworks.diskimages skip-verify -bool true # don't verify mounted DMGs

Not hidden

defaults write -g AppleEnableSwipeNavigateWithScrolls -bool false # Swipe between pages
defaults write -g InitialKeyRepeat -int 15 # in milliseconds, shortest shown in System Preferences is 15
defaults write -g KeyRepeat -int 2 # fastest shown in System Preferences is 2
defaults write -g com.apple.keyboard.fnState -bool true # Use all F1, F2, etc. keys as standard function keys
defaults write -g userMenuExtraStyle -int 2 # Show fast user switching menu as: icon
# Already included in .osx
defaults write com.apple.finder AppleShowAllExtensions -bool true # Show all filename extensions
mathiasbynens commented 13 years ago

Woah, thanks @Lri! Will go over these and cherry-pick.

I noticed AppleShowAllExtensions is not in the com.apple.finder domain (at least not on Lion). Looks like it should be defaults write NSGlobalDomain AppleShowAllExtensions -bool true.

necolas commented 12 years ago

Is there an option to automatically enable snap-to-grid on desktop icons?

mathiasbynens commented 12 years ago

@necolas Added in dda45e2.

FWIW, this is how I find the correct keys:

  1. defaults read > a
  2. Change the setting
  3. defaults read > b
  4. diff a b

If that doesn’t work, I usually try to run strings on the binary and look for anything that resembles a preference name.

(There might be a better way, so please let me know if I’m being silly!)

Update: Lauri Ranta shares some more tricks on how to discover hidden preferences: http://osxnotes.net/defaults.html


Unfortunately, in this case it’s a list and not a simple property, so we can’t just use defaults write. PlistBuddy to the rescue!

# Enable snap-to-grid for desktop icons
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist

Thanks for the suggestion, I should’ve added this one sooner.

necolas commented 12 years ago

Awesome, thanks. Been looking for this one.

ghost commented 12 years ago

A few more hidden preferences that aren't currently included in .osx and I didn't mention before.

# Display ASCII control characters using caret notation in standard text views
defaults write -g NSTextShowsControlCharacters -bool true

# Add a context menu item for showing the web inspector to web views
defaults write -g WebKitDeveloperExtras -bool true

# Disable the animation for showing and hiding information panels in Finder
defaults write com.apple.finder AnimateInfoPanes -bool false

# Don't open a Finder window when mounting an external disk
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool false

# Make Safari's search banners default to Contains instead of Starts With
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
mathiasbynens commented 12 years ago

Thanks, @Lri!

3vincent commented 12 years ago
External drives remain mounted after logout / externel drives are mounted before first login (works for 10.6+)
$ sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisksWithoutUserLogin -bool true

Address Book Debug Menu
$ defaults write com.apple.addressbook ABShowDebugMenu -bool YES

iCal Debug Menu
$ defaults write com.apple.iCal IncludeDebugMenu YES

Time Machine: Support for unsupported Network Volumes 
$ defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Time Machine: Change Interval of Backups (1800 = 1800 seconds)  
$ sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 1800

Set Limit Of Safari History Elements to a NUMBER
$ defaults write com.apple.Safari WebKitHistoryItemLimit 2000

Set Limit Of Safari History Elements to a Number of DAYS
$ defaults write com.apple.Safari WebKitHistoryAgeInDaysLimit 30
mathiasbynens commented 12 years ago

Thanks, @3vincent! I’ve enabled the iCal and Address Book debug menus. The other settings are interesting too, but I personally don’t need them — good thing you’ve posted them here for other people to learn though! Thanks again.

mathiasbynens commented 12 years ago

@necolas pointed me to http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/ — some of the listed commands have been proposed here before. I should consider adding them to .osx in commented form anyway, so it’s easier for other people to use.

mathiasbynens commented 12 years ago

Here are some more: http://www.johnkastler.net/2011/12/25/os-x-defaults/ Also note that stuff like -string "NO" can in some (?) cases be written as -bool false instead (which makes more sense, IMHO).

necolas commented 12 years ago

Needs more inline comments!

mathiasbynens commented 12 years ago

@necolas Don’t worry, I’ll take care of that :)

franciscolourenco commented 12 years ago

It would be useful to have a separate repository only with osx stuff which could be included in everyone's dotfiles

mathiasbynens commented 12 years ago

@aristidesfl But it’s just a single file. I don’t see how anyone would benefit from having a separate repository.

franciscolourenco commented 12 years ago

@mathiasbynens

The idea would be to keep a repository with a central impartial collection of potentially useful Max OS X settings. This would become the place of reference for this kind of settings, and everyone could make pull requests with the new additions without affecting your personal preferencies.

This would potentially allow people to fork the repo on github; create a branch to keep only the preferences they would like to see applied in their system ((un)commenting); and include that customized branch in their own dotfile repo via submodule/subtree.

This way, you could include in your dotfiles a customized branch of the collection with only the preferences which interest you. If someone doesn't want to use git to include the file they can still just copy or execute it directly from github.

Advantages

Other details

telemachus commented 12 years ago
# Remove scroll bouncing
defaults write -g NSScrollViewRubberbanding -int 0
mathiasbynens commented 12 years ago

@telemachus That’s a nice touch. Unfortunately it only seems to actually remove the scroll bouncing effect in a few apps such as Finder. Safari, for example, still has it. :(

wamatt commented 12 years ago

Out of interest, any reason imagemagick included, but commented out by default?

IE what significance or meaning does that have (if any).

oops - sorry that should be in the .brew suggestions

mathiasbynens commented 12 years ago

I don’t want to install imagemagick by default on all the machines I work on, only on my own laptop. Listed it in .brew is like a reminder to me — “hey, you might want this too. Or not.” (For the same reason, some .osx commands have been included in commented out form.)

wamatt commented 12 years ago

OK thought it was something like that (:

mathiasbynens commented 11 years ago

FWIW, @pornel suggested to look into dtrace. From https://twitter.com/pornelski/status/392985675584516096:

I haven't played with dtrace yet, but AFAIK you can intercept method calls, so you could log every preference read.

mathiasbynens commented 10 years ago

Some more goodies: https://github.com/amlweems/tilde/commit/8f92281088b47ec1952db3c1a408ad414c7ab046

hkdobrev commented 10 years ago

Here are even more: https://github.com/hjuutilainen/dotfiles/blob/master/bin/osx-system-defaults.sh and more https://github.com/hjuutilainen/dotfiles/blob/master/bin/osx-user-defaults.sh

kevinSuttle commented 10 years ago

Just a heads up to anyone subscribed to this thread: https://github.com/kevinSuttle/OSXDefaults/blob/master/REFERENCE.md

kornelski commented 10 years ago

@mathiasbynens Re: dtrace http://pastebin.com/QRbJQs5M

#!/usr/sbin/dtrace -q -s

CFPreferencesServer$target:::request {
   printf("REQUEST from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", arg0, walltimestamp, copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4), arg5);
}

CFPreferencesServer$target:::write_rejected {
   printf("REJECTED WRITE request from pid %d for reason %s at %Y ( domain: %s, user: %s, host: %s, container: %s)\n", arg0, copyinstr(arg5), walltimestamp, copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4));
}

CFPreferencesServer$target:::write {
   printf("ACCEPTED WRITE from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s)\n", arg0, walltimestamp, copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4));
}

/*
CFPreferencesServer$target:::cache_miss {
   printf("CACHE MISS from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", arg0, walltimestamp, copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4), arg5);
}
*/

CFPreferencesServer$target:::read_rejected {
   printf("REJECTED READ request from pid %d for reason %s at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", arg0, copyinstr(arg6), walltimestamp, copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4), arg5);
}

CFPreferencesServer$target:::read {
   printf("ACCEPTED READ from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", arg0, walltimestamp, copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4), arg5);
}

CFPreferencesServer$target:::persist {
    printf("SAVING %s TO DISK at %Y\n", copyinstr(arg0), walltimestamp);
}

CFPreferencesServer$target:::error {
    printf("ERROR %s at %Y\n", copyinstr(arg0), walltimestamp);
}

BEGIN
{
    printf("Monitoring cfprefsd instance %d\n\n", $target);
}