Skip to content

Instantly share code, notes, and snippets.

@karimofthecrop
Last active August 29, 2015 13:58
Show Gist options
  • Save karimofthecrop/10430448 to your computer and use it in GitHub Desktop.
Save karimofthecrop/10430448 to your computer and use it in GitHub Desktop.
Fix OSX

Introduction

Anyone who has done regular programming in a Linux environment is quite shocked when forced to sit at a Mac: the terminal program doesn't have niceties installed, there are too many keyboard modifier keys, the home/end/page-up/page-down keys don't behave as expected, and much much more.

Whether or not you suffer when using a Mac to program, this page will allow you to get your environment to an arguably optimal state.

Problem: page-up/page-down/end/home are "broken", as are most inter-program keyboard shortcuts

Install better touch tool

Unplugging monitors loses windows

Sometimes you unplug a monitor and a window will with the window control buttons above the screen. In Linux, you just press and hold Alt, and you can drag the window back down, but not in Mac.

Download Stay: http://cordlessdog.com/stay/

I need my screensaver timeout short so I don't lose battery, but sometimes I want to disable that.

During presentations, you sometimes want to temporarily disable the screensaver/screenlock.

Install caffeine, and set it to be 2 hour timeout: https://itunes.apple.com/us/app/caffeine/id411246225?mt=12

I NEED the One True Editor

Install GNU Emacs: http://emacsformacosx.com/

Make emacs do "the right thing" when you are typing in a shell

edit ~/.bash_profile

alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw"

Can I please paste plain-text?

Shift + Option + Command + V pastes with the formatting of the document you are pasting into (not from), which is sorta the same thing. It won't carry across the formatting from the previous document.

  • Open 'System Preferences', select 'Keyboard'
  • Select tab 'Keyboard Shortcuts'
  • Select 'Application Shortcuts' from the left listbox
  • Click '+' below right listbox
  • Select 'All Applications' for 'Application' input box
  • Type 'Paste and Match Style' into the 'Menu Title' input box
  • In the 'Keyboard Shortcut' input box, pretend that you are about to paste something by typing command-v. There should now be the cloverleaf command sign followed by a -v in this box.
  • Click add.

Why is this Mac so slow?

My mac slows down for mysterious reasons sometimes. Most of the time it is obvious if I have proper monitoring in place.

Install hardware utilization monitors: http://www.ragingmenace.com/software/menumeters/index.html

WTF. Does anyone at apple use Finder?

Unstupid Finder:

I need Open Source software

Install HomeBrew: http://mxcl.github.com/homebrew/

NOTE: This requires XCode be installed.

I hate the Mac Terminal program

For an integrated shell, iterm2 isn't bad.

At one time I used xterm, but it was hard to overcome the "non-nativeness" of X11 apps...

Man, these shell defaults are just weird.

PAGER is set to more? EDITOR vi? What decade is this from? Step into the '90s with these settings:

Edit ~/.bash_profile:

# Set this to your preferred editor
export EDITOR="emacs" # alias set above

# Set this to get a modern pager in man pages
export PAGER=less

God these shell fonts are ugly

Install inconsolata: http://www.levien.com/type/myfonts/inconsolata.html

Where is all the tab-completion yumminess I am accustomed to?

This is the number one complaint heard. For some reason, robust tab completion has been an integral part of the Linux shell experience for ever. Why this isn't the case with all *nix flavored shells is baffling.

Install bash-completion package with:

brew install bash-completion

Then follow the instructions it gives for editing .bash_profile

Wait, git isn't completing...

Based on docs found here http://git-scm.com/book/en/Git-Basics-Tips-and-Tricks:

CFILE=/usr/local/etc/bash_completion.d/git
sudo curl -o $CFILE https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
sudo chmod a+x $CFILE

What about git shortcuts while we're at it?

Edit ~/.gitconfig

[alias]
        co = checkout
        ci = commit
        rb = rebase
        st = status
        br = branch
        up = pull

Ok. All I need is the One True Editor (when not using magit) for git commit messages and my life is complete

edit ~/.gitconfig:

[core] editor = /Applications/Emacs.app/Contents/MacOS/Emacs -nw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment