You are on page 1of 240

Mac

Table of Contents
1. Introduction
2.
i. Mac
3.
i.
ii.
iii.
4.
i.
ii.
iii.
iv.
v.
vi. AirPlay
5.
i. U
ii.
iii. XCode
iv. Homebrew
i. Usage
ii. Cask
iii. Create
v. MacPorts
vi. Shell
i. iTerm2
ii. ZSH
iii. tmux
vii. Git
i. Git ignore
ii.
iii. Dotfiles
viii. -Sublime Text
i.
ii. Packages
iii.
iv. SublimeLinter
v.
ix. -Atom
x. Ruby
i. RubyGems
xi. Node.js
i. N and NVM
xii. Python
i. Pip
ii. Virtualenv
iii. Virtualenvwrapper
xiii. Java
xiv. MySql
xv. Latex
2

Mac

6.
i. xhyve
ii. Vagrant
i.
ii.

Mac

Mac
Welcome to s Book!
Mac
MAC OSX MAC Windows
Mac

-China

Introduction

Mac

Mac

Introduction

Mac

AirPlay

XCode
Homebrew
Usage
Cask
Create
MacPorts
Shell
iTerm2
ZSH
tmux
Git
Git ignore

Dotfiles
-Sublime Text

Packages

SublimeLinter

-Atom
Ruby
RubyGems
Node.js
N and NVM
Python
Pip
Virtualenv
Java
MySql
Latex

xhyve
Vagrant

Introduction

Mac

2015 ztd811@gmail.com

Mac

Mac
Mac /web/IT Mac Mac
Mac

Mac OS X Unix
Unix
windows windows cygwin flex/yaccgrepscreensshmake
open source cygwin/gcc/make Mac BSD Unix built in

c/c++/java/perl/python/php/ruby/lisp shell windows C++


Visual Studio C++ Java Java SDK Elipse
Netbean Perl Perl Active Perl python/php/ruby
Unix/Linux Mac Unix Mac

Vi/Emac
/IT / Mac 1/2
browser/email1/2 Vi

/
5 Mac Mac

Mac Mac 5
Mac

Mac Mac
1 windows USB
Mac 1windows

///

Unix /90 DOS


Windows Microsoft Mac Unix Mac
Unix Mac Unix hacker Web 2.0/Linux hacker
fans Ruby on Rails
Web Ruby

Mac

Mac

Mac Designed by
Apple in California Desgined in USA

Apple/Google/Microsoft/Amazon/eBay/Yahoo
Mac
2007 Mac
Mac
VPSee Top Language [TL] Re: [] Mac
TechCrunch Hacker

Mac

Mac

Mac
-MacMaciCloud

Apple IDiCloud@iCloud.comApple ID
iCloudApple IDiWork

Mac

10

Mac

IP
GmailDropboxFeedlyVPNSSLedge

WIFI- -

IPDNS

11

Mac

1. Wi-FiDNS

Gmail
HomeWork
2. +VPN
3. VPNVPNPPTPL2TP
VPNVPNVPN

VPN
1. WIFIWi-FiThunderbolt Ethernet

WiFi

ADSL

* WIFI
* Terminal

sudo route -n add 192.168.1.0/16 192.168.1.1

192.168.1.0/164255.0.0.08255.255.0.016
255.255.255.0192.168.1.1
RouteMac

1. WIFIWIFIWIFIWIFI

12

Mac

iCloud-iCloudiCloudiPhoneiPadWIFI
WIFI
iCloud
1. TCP/IPIPTCP/IPIP

2. DNSDNS114.114.114.114114.114.115.115 DNS

DNS Ali223.5.5.5223.6.6.6 V2EX199.91.73.222178.79.131.110 Google8.8.8.88.8.4.4 Open


DNS208.67.222.222208.67.220.220
1. VPNGmailDropbox
HttpSocksSocksDropbox
VPNVPN
VPN
SSL
Mac MacbookWi-Fi

WANInternetLAN

1. LANLANLANMac
TCP/IPIPv4IPIP

LANLAN IP
192.168.1.1IP
1. WANMacIPTCP/IP
DHCPDHCPIP
LANWANIPIP
DHCP

OS XGoogleYahoo163126QQ

POPIMAPPOP
POP IMAP

POPIMAPPOP
POP.163.comIMAPIMAP.163.com

13

Mac

1. well@gmail.com
2. ;
3.

4. IMAP993
SSLPOP110SSL

SSL
SMTPSSL

Mac WindowsMacWindows
MacFinder
MacAirDropFinderAirDrop

14

Mac

WIFI AirDrop AirDrop


AirDrop
AirDrop Finder
-
1. Finder -
2. Macintosh HD--
3. Finder
4. -
5.

Windows WindowsMac
1. NetBIOSWindows
--WINS

15

Mac

--WINS
1.
Guest

Guest

16

Mac

-
guest
OKWindowsMacMac
\\IP \\

MacWindows WindowsMac\
\\-

MacFinder- smb://IP Windows


10.211.55.3WindowsIP

17

Mac

OS X

MacWindowsMac

- -

Advanced

24AMPM

18

Mac

Web

+
-
commandcommand

pkg-

capslock

iCloudMac
iPhone

19

Mac

airdropAirDroppingmim

shiftoption9shift
optionK

20

Mac

fnshiftoptionshiftoption

controlcommand


shiftoptionBshift6

21

Mac

shift
optiontab1234
controlshiftcommandC (C)controloption
shiftcommandC (C)

MacLaunchpad-

22

Mac

/System/Library/Fonts/Library/Fonts
Finder
WindowsMac

MacWindows
iWorkMac OfficeWindows
WindowsMac
MacWindows
Mac12Windows
9=
10.5=
12=
14=
15=
iWorkWindowsMacMailOutlook
Outlook
Mail-

PDF
Windows

23

Mac

UnicodeANSI
MacWindows

WindowsANSIMacUnicode
MacWindows

Unicode
Symbol MapHTML
MacWindows 00003.html
Universal MailerMailMail

TXTWindowsMacWindows

Mac OS X LFWindows CR+LF Windows


LF LF Windows
Windows Notepad++
UTF-8 BOM
MacWindowsANSI
TextWranglerFile-Reopen Using Encoding-Chinese GBK

WindowsMac OS X ZIP
UTF-8 ZIP PKZIP Unicode Windows ANSI
MacWindows.7zMac
The Unarchiver
Mac7zKeka
Windows7z

24

Mac

25

Mac

MacMacTime Capsule

1Time Machine

2Time Capsule

3FileVault

Mac OS X
WindowsMacMac OS XWindows

MacSafari



Mac App Store

Mac

26

Mac

Mac
Mac

Parallels DesktopOnyXPopClipMoom
MacOS X Mac

FileVault
Mac
FileVaultWIFIFileVault
U
FileVault

OS XFileVault

27

Mac

DMG
FileVault FileVault
Time Machine
Time Machine

Time Machine-

FileVault
1.
2. option
3. Uoption

4. Time Capsule

28

Mac

OS X FileVault 2 OS X Mavericks: FileVault


Time Capsule --AirPort Time Capsule

Time Capsule
Time Capsule

29

Mac

Time
MachineTime Machine
U UU

U
1. U

30

Mac

2.
3. U
U

Finder--256AES

OS XFTPSSHTime capsule
Wi-FiWi-Fi

Web
HTTPS

Finder--

31

Mac

China Internet Network Information Center CNNIC ROOT

CNNIC

1. -Mission Control-

2. Apple ID Apple ID
Apple ID Apple ID

3. OS X iCloud

4.
5. WIFIVPN
6. Safari
7.
8. MacMacTime Machine

9. OS X

32

Mac

AI

Mac
WindowsOS XFinder

Mac

33

Mac

OS XSafari

OS X

PDFTXTDOCPAGEJPEGTIFFGIFPNGMOVMP4

PDFPDF
PDF
PDF-
Shift Command

OS X PDF
PDFFinderPDF

TXTPDFDOCPAGE
--

defaults write com.apple.finder QLEnableTextSelection -bool TRUE;killall Finder

defaults delete com.apple.finder QLEnableTextSelection;killall Finder

OnyXOnyXMac

34

Mac

Safari
OS XSafari Apple

iCloudSafari
MaciPadiPhoneiPhone
MaciPhoneiPad

Safari+shift command
DSafari
iCloudiPadiPhone

Evernote Web Clipper


Evernote
Evernote60MB
Evernote

commandCcommandVMac

DockDock
Evernote
shift command Y

PopClip
EvernoteMarkdown
PopClip

EvernoteSafari

35

Mac

blockAdblockAdblock Plus

ClickToPluginFlashHTML5FlashCPU
ClickToPluginforChina
Google
CustomReaderSafariSafari

Safari
CSS
Safari CSS.CSSSafariSafari
--Helvetica Neue

Safari
Safari

36

Mac

Safari-
Safari Safari

SafariSafari
Safari

37

Mac

WindowsOffice WordExcelPowerPointOutlookProject
VisioAdobePhotoshopAcrobatMaciWorkPagesNumbers
KeynoteMailOmniPlanOmniGrafflePixelmator
Mac
Parallels DesktopWindows

Office
Parallels DesktopWindowsMacMacWindows
Parallels Desktop

Maccommandtab
Time Sink

FinderDropbox
Windows
Finder
Finder

Finder

Finder
MacSpotlightcontrol +SpotlightMac
Spotlight

38

Mac

SpotlightFinder
Time Machine
-SpotlightSpotlight-
SpotlightSpotlight

Finder

Finder-AutomatorHazel

39

Mac

HazelHazel
Stop Hazel

Hazel

1. ScrivenerPagesNumberKeynoteOmniGraffle

Hazel1

40

Mac

1. DEVONthink
docxlsMacMac

1.

1.

Hazel
Hazel

SpotlightTime Machine

41

Mac

TimeCapsule

MacQQDroplrEvernoteOS X

34shift+command+4
OS X
OS X--10

PNG.png
OnyXOnyX
Mac

42

Mac

PngScreenshot
Hazel

SkitchVoilaSnagit

43

Mac

Skitch
Voila
Snagit

Dock
shiftcommandY
EvernoteDay One
XMindMindNode PRO
ScappleScapple
CurioXMindMindNode PRO

44

Mac

PDFPNGRTFTXTOPML

PDF

Evernote

iPhoto
DropboxiPhoto

optioniPhoto

InboardEmber
TogetherDEVONthink Pro
PDFPapersPDF

DEVONthink20Words3

45

Mac

46

Mac

POP3SMTPIMAP
MacGmail163QQ
Mail
QQiMessage

MailOutlook
MailOutlookMailOutlook
OutlookWindowsOutlook for MacOutlook
Windows

WindowsOutlookpstpstGB
Mac
OutlookWindows
OutlookParallels DesktopWindowsOffice
Office
WindowsOutlookMacMail
OutlookpstMacOutlook
MailTime Machine
Mail
Mail-shift+command+M
VIP

-
Mail

47

Mac

VIPMail
VIP VIPVIP
MailVIPVIP

48

Mac

PopClip
RemindersOmniFocus
OmniFocus

49

Mac

50

Mac

option+command+LL

Mail
Mail-
Mac
---
1.
iCloudiPhone
+
delete

iCloudMacGoogle


MacGoogle163
iCloud

200+

iCloudApple IDMaciPhone

51

Mac

MacGoogle163

1. -

2.

CSVMacvCardCSVGoogle163
WebCSVNumberExcelCSV

CSV

1.
14

1.

52

Mac

Mail-

-
1. Safarishift+command+II
command+II
2.
zip
7z
YosemiteMail
Mail DropMail iCloudMail
Mail

MacWindows 00003.html

53

Mac

Universal MailerMailMail

1.

MacApple IDiMessage
PKiPhoneOS X Yosemite
OS X
IDApple ID
QQ
QQ for MacWindowsSwiftly

iPhoneiPhoneQQQQ
MaciPhone

MaciOSInstashare
Command-CMaciOS
Command-CInstashare
Instashare

OS X YosemiteiOSMacAirDrop
iPhone 4s4.0iOSMacbook

QQ
DropboxMaciPhone

DropboxWeb

54

Mac

Mac
Mac

Time Machine
Mac

55

Mac

MaciPhone

GTDMac
MacGTD

App Store
OmniFocusWunderlistClearThingsTodoFantastical

GTDGetting Things Done

MaciPhone
GTD

56

Mac

MaciPhoneiCloud -

MaciPhoneiCloud

Need to do something
Sometime to do something

57

Mac

Mac+
Dock

iCloudhttps://www.icloud.comWeb
Apple
iCloudPagesNumbersKeynote

OutlookiCloud
WindowsiCloudOutlookiCloud
MaciPhone

58

Mac

OutlookiCloud
iCloudOutlookiCloudiCloud

iCloudMac

MaciPhoneiMessage

PopClip
PopClipNoteReminders
RemindersNote

iCloud
MaciPhoneiCloudMaciPhone
Apple IDiCloud

59

Mac

Yosemite iOS 8

FamilyFamily

Mac
OmniFocus OmniFocus
OmniFocus 2 for Mac

60

Mac

MacTime Machine
iTunesiCloud1Password

Time Machine
Time MachineTime MachineMac OS X
FSEvents()Time Machine
(incremental backup)
Time MachineTime Capsule

command+R Time Machine


Time Machine
Time MachineTime Machine

Time Machine

Time Capsule Time Capsule

61

Mac

Time Machine...Time MachineTime Machine


Time MachineFinder

Time Machine

Backups.backupdb
Time Machine

1.
5GHzWi-Fi10-13MB/s
GBPapersDEVONthink Pro
DEVONthink ProTime Machine
Time Machine
2. -
Power NapMac

DEVONthink ProParallels DesktopThunderbolt

Time Machine

62

Mac

MacMacWindows
Mac
Windows PC
Time MachineTime
Machine
Time Machine Mac
Mac Time Machine
Mac Mac/

Time Machine
Mac Time Machine

FileVault FileVault Mac Mac


FileVault

iTunes
iCloudiTunesAppiPhoneiPadApp Store
iTunesPodcast-iTunes
iTunes Library.itl

iTunesNAS5GHz
Wi-Fi
iTunes
iPhoneiTunesiPhoneiTunes
iTunesiTunesiPhone
MaciTunesMac

63

Mac

iPhoneiPhone5
iTunesiPhone
iTunesPodcast

iCloud
iCloudiCloudiCloud
MacPagesNumbersKeynoteDay OneUlyssesPixelmator

64

Mac

iCloudiCloudiCloudiCloud
iCloud

OS X 10.10iCloud DriveiCloud
iCloud DriveFinderDropboxFinder
DropboxDropbox

SafariiCloud
MaciOSSafari

65

Mac

SafariSafari-

Safari--
Time CapsuleWIFI

66

Mac

Wi-FiTime CapsuleWIFI
WIFISSIDWIFI
WIFI
iCloudiOSMacMacWIFIiPhone
WIFI
WIFISSID

1Password
SafariChromeSafariFirefoxOpera
1Password
Ftp
1PasswordWindowsMaciOSAndroidiCloudDropbox

67

Mac

1PasswordDropbox1Password
Dropbox
1PasswordDropboxDropboxDropbox1Password

Apple IDGmail

68

Mac

AirPlay
MacSafariMac
iTunesPhoto BoothiMovieGarageBandQuickTime PlayerAirPlay
Photo BoothiPhotoiMovie
GarageBandiLife
AppleiPhotoAperture10.10
PhotosiMovieFinal Cut Pro XGarageBandLogic Pro
iPhoneiMovie
iPhoneGarageBand
Mac

iPhone

iMovie
iMovieGarageBandiTunesQuickTime Player
AppleAirPlayApple TV

iTunes
iTunesAppleiPhoneiTunes
Windowsshift+
iCloudiTunesiPhoneiPhoneApp
iCloudiTunes
MaciPhotoiTunes

AirPlay

69

Mac

1. AirPlayAirPlayApple TV
2. iOSApple TV iTunes Mac
iPhoneiPadApple TVMac iTunes
3. 40ACC
Finderm4am4riPhone
4.
5.
iPhoneiTunesiPhoneiTunes
iTunesiTunesiPhone

QuickTime Player
MacQuickTime PlayerSafariFinder
QuickTime Player .mov.mp4.avi.mp3.aiff.m4a.wav
QuickTime Player .wmv.divx.mpeg.mxfFlip4Mac
MPlayerXVLC
QuickTime Player-

AirPlay

70

Mac

QuickTime
.mov

Apple TVAirPlay
Apple TV

Apple TVWIFIHDMI
Apple TVYoutube
PodcastiCloudApple TVAirPlayAirPlay
MaciPhoneiPadApple TV
iPadiPhoneAirPlay
AirPlayAppleWIFIMaciPod touchiPhoneiPad
AirPlayApple TVAppleAirPlay
AirPlayWIFIAirPlayAirPlay
AirPlay

iTunes-AirPlay
HDMI+ Apple TV
HDMI+ Apple TVApple TVAirPlay
iPhoneiPadiOS AirPlay WIFIiOS
KeynoteKeynotePPT

AirPlay

71

Mac

MacApple TV
MacMacMac

AirPlay

72

Mac

MacMac

OS X Mavericks
Option

AirPlay

73

Mac

option
AirPlayVLCAudio-Audio Device
Mac

AirServer
Apple TVAirPlayAirServerMacAirServer
MacApple TV AirPlay
AirServerComputer NameiPhone AirPlay

AirServerMaciPhoneMacHDMI
AirServeriPadiPhoneAirPlayiPhone
AirPlay

WIFI

AirPlay

74

Mac

WIFIMaciPhoneWIFI
MaciPhone-WIFIMac
AirPlayAirServerMac
Mac
WIFI

AirPlay

75

Mac

MacBook Web Mavericks Yosemite

76

Mac

Yosemite U
Yosemite App Store 5.17GB
Yosemite U

- Yosemite
8GB U - - Mac OS X
Untitled
- -
sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled -applicationpath /Applications/Install\ OS\ X\ Yosemite.app --nointeraction

return

77

Mac

Done

UDiskmakerx
Yosemite

78

Mac

Uoption
U

79

Mac

> >

>

Dock

Dock
Dock

Finder
Finder >

>
Finder >

Finder HOME

HOME
(shared) (tags)

Spotlight

80

Mac

iCloud Find my mac

81

Mac

XCode
App store Xcode
Xcode command line tools

xcode-select --install

Xcode command line tools

iOS OS X XCode Xcode command line tools


terminal make, GCC, clang, perl, svn, git, size, strip, strings, libtool,
cpp

Xcode command line tools /Library/Developer/CommandLineTools/

ar
as
asa
bison
BuildStrings
c++
c89
c99
cc
clang
clang++
cmpdylib
codesign_allocate
CpMac
cpp
ctags
ctf_insert
DeRez
dsymutil
dwarfdump
dyldinfo
flex
flex++
g++
gatherheaderdoc
gcc
gcov
GetFileInfo
git
git-cvsserver
git-receive-pack
XCode

82

Mac

git-shell
git-upload-archive
git-upload-pack
gm4
gnumake
gperf
hdxml2manxml
headerdoc2html
indent
install_name_tool
ld
lex
libtool
lipo
lldb
lorder
m4
make
MergePef
mig
mkdep
MvMac
nasm
ndisasm
nm
nmedit
otool
pagestuff
projectInfo
ranlib
rebase
redo_prebinding
ResMerger
resolveLinks
Rez
RezDet
RezWack
rpcgen
segedit
SetFile
size
SplitForks
strings
strip
svn
svnadmin
svndumpfilter
svnlook
svnrdump
svnserve
svnsync
svnversion
unifdef
XCode

83

Mac

unifdefall
UnRezWack
unwinddump
what
xml2man
yacc

XCode

84

Mac

Homebrew
OS X Homebrew.

Homebrew Xcode Command Line Tools Xcode Command Line


Tools Homebrew
terminal $ Hombrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Homebrew ( /usr/local/bin
/usr/local/bin $PATH :

$ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

Cmd+T terminal brew

$ brew doctor

Homebrew /usr/local git


brew sudo

Homebrew

85

Mac

Homebrew
brew search * -
brew install * -
brew uninstall * -
brew list
brew update Homebrew
brew home *
brew info *
brew deps *
brew server * webhttp://localhost:4567/
brew -h brew

homebrew
cd /usr/local/
git remote set-url origin http://mirrors.ustc.edu.cn/homebrew.git
brew update

cd ~/tmp
git clone http://mirrors.ustc.edu.cn/homebrew.git
rm -rf /usr/local/.git
rm -rf /usr/local/Library
cp -R homebrew/.git /usr/local/
cp -R homebrew/Library /usr/local/
brew update

homebrew-sciencehomebrew-python
cd /usr/local/Library/Taps/homebrew/homebrew-science
git remote set-url origin git://mirrors.tuna.tsinghua.edu.cn/homebrew-science.git
cd /usr/local/Library/Taps/homebrew/homebrew-python
git remote set-url origin git://mirrors.tuna.tsinghua.edu.cn/homebrew-python.git
brew update

CategoryMirrorUsage

node-canvas ()
1.pkg-config

$ curl http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz -o pkgconfig.tgz


$ tar -zxf pkgconfig.tgz && cd pkg-config-0.28
$ ./configure --with-internal-glib && make install

Usage

86

Mac

2.pixman

$ curl http://www.cairographics.org/releases/pixman-0.30.0.tar.gz -o pixman.tar.gz


$ tar -zxf pixman.tar.gz && cd pixman-0.30.0/
$ ./configure --prefix=/usr/local --disable-dependency-tracking
$ make install

3.libpng & export ...

$ brew install libpng


$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig

4.node-canvas

$ npm install canvas


or from source:
$ node-gyp rebuild

5.

Error: error while reading from input stream


or:
Error: Image given has not completed loaded

brew install giflib # for .gif files


brew install libjpeg # for .jpg files

node-canvas

brew install wget watch tmux cmake openssl imagemagick graphicsmagick gearman geoip readline autoconf multitail source-highlight autoju

vim
brew install ctags macvim --env-std --override-system-vim
#### Cakebrew

Cakebrew Cakebrew App brew

Usage

87

Mac

Homebrew Cask
Homebrew Homebrew Cask
OS X Google Chrome Dropbox

Homebrew-cask

$ brew tap phinze/homebrew-cask


$ brew install brew-cask
$ brew cask install google-chrome // Google
$ brew update && brew upgrade brew-cask && brew cleanup //

cask app caskroom.io

Mac markdown json

Quick Look plugins


List of useful Quick Look plugins for developers

Install
Using Homebrew Cask
Run brew cask install <package>

Install all

brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json qlprettypatch quicklook-csv betterzipql qlimagesize webpquicklook sus

Manually
Click "download manually"
Move the downloaded .qlgenerator file to /Library/QuickLook
Run qlmanage -r

Plugins
QLColorCode
Cask

88

Mac

Preview source code files with syntax highlighting


Run brew cask install qlcolorcode or download manually

QLStephen
Preview plain text files without a file extension. Example: README, CHANGELOG, etc.
Run brew cask install qlstephen or download manually

QLMarkdown
Preview Markdown files
Run brew cask install qlmarkdown or download manually

Cask

89

Mac

QuickLookJSON
Preview JSON files
Run brew cask install quicklook-json or download manually

QLPrettyPatch
Cask

90

Mac

Preview .patch files


Run brew cask install qlprettypatch or download manually

QuickLookCSV
Preview CSV files
Run brew cask install quicklook-csv or download manually

BetterZipQL
Preview archives
Run brew cask install betterzipql or download manually

Cask

91

Mac

qlImageSize
Display image size and resolution
Run brew cask install qlimagesize or download manually

Cask

92

Mac

WebP
Preview WebP images
Run brew cask install webpquicklook or download manually

Suspicious Package
Preview the contents of a standard Apple installer package
Run brew cask install suspicious-package or download manually

Cask

93

Mac

More
These are not included in Install all.

ProvisionQL
Preview iOS / OS X app and provision information
Run brew cask install provisionql or download manually

Other
CertQuickLook - preview various unprotected certificate tokens like X509 certificates, DER or PEM

Cask

94

Mac

Tip
Run this in your terminal to allow text selection in the Quick Look window:

defaults write com.apple.finder QLEnableTextSelection -bool true && killall Finder

OS X
$ brew cask install alfred
$ brew cask install appcleaner
$ brew cask install cheatsheet
$ brew cask install dropbox
$ brew cask install google-chrome
$ brew cask install onepassword
$ brew cask install sublime-text
$ brew cask install totalfinder
...

brew cask App Store OS X

Alfred Spotlight ~/Application


Alfred brew cask /opt/homebrewcask Alfred

brew services
homebrew brew services homebrew
nginx, mysql

brew tap homebrew/services

Install and start service mysql at login


$ brew install mysql
$ brew services start mysql

Stop service mysql:

$ brew services stop mysql

Restart service mysql:

$ brew services restart mysql

Install and start dnsmasq service at boot


Cask

95

Mac

$ brew install dnsmasq


$ sudo brew services start dnsmasq

SYNOPSIS
# [<sudo>] `brew services` `list`<br>
# [<sudo>] `brew services` `restart` <formula><br>
# [<sudo>] `brew services` `start` <formula> [<plist>]<br>
# [<sudo>] `brew services` `stop` <formula><br>
# [<sudo>] `brew services` `cleanup`<br>

LaunchRocket homebrew cask


brew tap jimbojsb/launchrocket
brew cask install launchrocket

Cask

96

Mac

Brew
homebrew BettyhomebrewFormula

1. Formula
brew create betty
2. githubformula
betty.rb
brew edit betty
rbbrew edit
1. betty
brew install betty

Create

97

Mac

MacPorts
MacPortshttp://www.macports.org
ports treeMacPorts-v

sudo port -v selfupdate

port search name

sudo port install name

sudo port uninstall name

port outdated

sudo port upgrade outdated

EclipsesubclipseJavaHLMacPorts

sudo port install subversion-javahlbindings

MacPorts

98

Mac

Shell

shellshell
shell
shellshell
sshLinux/Unixshell

shell script
shellBourne Shell C ShellKorn ShellBourne-again ShellTENEX C Shell cat
/etc/shells shell:

Linux/UnixBash(Bourne-again Shell)zsh
Oh My ZSHzshzsh

Shell

99

Mac

Shell

shellshell ~/.bash_history

!! ctrl-r

Shell

100

Mac

( tab )
tab
gi gi tab

cd tab

Shell

101

Mac

cocoapodsshell

pod update --verbose --no-repo-update

alias pod_update='pod update --verbose --no-repo-update'

pod_update cocoapod
alias

Shell

102

Mac

(job control)
shellshell
shellshell
(foreground)(background)
ctrl-c bg/fg

1. command + &
Shell

103

Mac

[1] job number() 7089 PID()stdout


stderr

2. ctrl-z
shell find / -print ctrl-z

find / -print job number [2]


3. jobs -l
jobs -l

Shell

104

Mac

PID 7417 7431 - + -


+
4. fg %jobnumber
fg + ctrl-z

PID 7431 jobs -l

fg %1
5. bg %jobnumber
jobs -l

bg %2; jobs -l kill


shell
6. kill -signal %jobnumber
kill
find / -print ctrl-z
Shell

105

Mac

kill -9 %1;jobs -l

shell script
shell scriptshellshellshell

shell

* 0
?
[] [abc]abc
[-] [1-7]17
a,b,c

iTerm 2(for mac) && Oh My Zsh


maciTerm 2, iTerm 2 mac Terminal
Oh My Zsh

Oh My Zsh
curl
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
wget

Shell

106

Mac

wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh
oh my zsh robbyrussell

zshoh my zsh ~/.zshrc

# Support autojump
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
# setup moco alias name
alias moco_service="moco start -p 12306 -g settings.json"
#setup macvim alias name
alias vim="/Applications/MacVim.app/Contents/MacOS/Vim"
#setup pod update alias name
alias pod_update='pod update --verbose --no-repo-update'

Themes ~/.zshrc
ZSH_THEME="robbyrussell" ZSH_THEME

ZSH_THEME="agnoster"

oh my zsh ~/.oh-my-zsh/themes
robbyrussell

PROMPT='%{$fg_bold[red]%} %{$fg_bold[green]%}%p%{$fg[cyan]%}%d %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%


#PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}>

c()d() >

oh my zsh ~/.oh-my-zsh/plugins

Shell

107

Mac

zshgit

git.plugin.zsh
~/.zshrc

plugins=(git autojump osx)

git
Shell

108

Mac

gitShell git branch gitPlugin:git


autojump
autojump

mac brew
brew install autojump
linuxautojump

git clone git://github.com/joelthelion/autojump.git

./install.py

~/.zshrc

[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

~/.oh-my-zsh/themes j themes ~/.oh-my-zsh/themes

osx
tab -
cdf - cdFinder
quick-look -
man-preview - Previewman page
trash -

1. zshbashbashzsh
2. cls

Shell

109

Mac

1. tab
2. autojump
3. d

1. ..

YouTube zsh shellOh My Zsh

shellshell
shell script
Don't repeat your self

shell
Unix/Linux

Shell

110

Mac

1.
2.

shell

shell devname=sam bash shellshell echo $devname


exit

Shell

111

Mac

export devname bash echo $devname


sam
env set
env

set shell

Shell

112

Mac

echo $variable
PATH

echo $PATH

$
variable=value unset
=

Shell

113

Mac

echo $devname

1.

1. =

blank can't exist.png


1. " " ' '
" "

' '

1. $! \
2. $()
Shell

114

Mac

$()

1. $variable

1. export
export VARIABLE
2. PATH HOME SHELL
3. unset variable $

Shell

115

Mac

/etc/profile ~/.bash_profile /etc/profile


~/.bash_profile oh my zsh
~/.bash_profile .zshrc TEST
export TEST=test .zshrc

.zshrc TEST echo $TEST source source


.zshrc TEST

(standard input)(standard
output)(standard error)

Shell

116

Mac

stdin 0 < <<

<
<<
stdout 1 > >>

>
>>
stderr 2 2> 2>>

2>
2>>

stdout
ls > dir.txt

> >> > stdout >>


stdout
ls > dir.txt stdout dir.txt

Shell

117

Mac

ls >> dir.txt dir.txt

stderr
ls test error.txt

2>>

stdout & stderr


stdoutstderr > 2>
ls README.md test
> 2>

Shell

118

Mac

stdoutstderr &>
&>

stdin

cat > test test

test <

Shell

119

Mac

<< << cat > test << "eof"


test eof

Unix--KISS(Keep it Simple, Stupid)

Shell

120

Mac

cat README.md | grep 'pod'


1. cat README.md
2. cat README.md grep 'pod'
| stdout stdin

Linux-
Unix Pipes
Linux Shell
(job control)
oh my shell
Shell

Shell

121

Mac

iTerm2
Mac
iTerm2
Finder iTerm Application Launchpad iTerm

Keys -> Hotkey command + option + i iTerm


Profiles -> Default -> Check silence bell
Solarized dark iterm colors Profiles -> Default -> Colors -> Load Presets
Profiles -> Text cursor

iTerm2

122

Mac

Zsh
zsh oh-my-zsh Env.sh aliasesexports
path changes ~/.zshrc

Zsh
Homebrew zsh zsh completions

brew install zsh zsh-completions

oh-my-zsh zsh

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

vi .zshrc :

ZSH_THEME=pygmalion
alias zshconfig="vi ~/.zshrc"
alias envconfig="vi ~/Projects/config/env.sh"
plugins=(git colored-man colorize github jira vagrant virtualenv pip python brew osx zsh-syntax-highlighting)

vi ~/Projects/config/env.sh :

#!/bin/zsh
# PATH
export PATH="/usr/local/share/python:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export EDITOR='vi -w'
# export PYTHONPATH=$PYTHONPATH
# export MANPATH="/usr/local/man:$MANPATH"
# Virtual Environment
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects
source /usr/local/bin/virtualenvwrapper.sh
# Owner
export USER_NAME="YOUR NAME"
eval "$(rbenv init -)"
# FileSearch
function f() { find . -iname "*$1*" ${@:2} }
function r() { grep "$1" ${@:2} -R . }
#mkdir and cd
function mkcd() { mkdir -p "$@" && cd "$_"; }
# Aliases
alias cppcompile='c++ -std=c++11 -stdlib=libc++'

source

ZSH

123

Mac

exit logout shell shell login

ZSH

124

Mac

tmux
tmux
tmux
tmux is a terminal multiplexer
What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep
running in the background) and reattach them to a different terminal. And do a lot more.

tmux

detachattach

HTTPrailsdjango
ssh

tmux

125

Mac

ssh
tmuxdetachattach

tmux http://t.cn/Rv6DnPb
tmux

tmux linuxMacFreeBSDWindows

linux
linux

Debian
$ sudo apt-get install tmux

$ sudo yum install tmux

Arch Linux
$ pacman -S tmux

Mac
Mac Homebrew Macports

Homebrew
$ brew install tmux

Macports
$ sudo port install tmux

FreeBSD
FreeBSDport

tmux

126

Mac

$ cd /usr/ports/sysutil/tmux
$ make install clean

Windows
Windows cygwin cygwincygwin Select Packages tmux

tmux tmux

$ tmux -V

tmux 1.8

1.9a 1.8 tmux 1.8

tmux

$ tmux

tmux
exit [Ctrl+d]
tmux Session tmux

tmux

$ tmux new-session -s <>

dev

$ tmux new-session -s dev

dev

tmux

127

Mac

new-session new

$ tmux new -s dev

$ tmux new -s <>

monitor top

$ tmux new -s monitor top

top top ( [q] )

detach
tmux exit [Ctrl+d] tmux
rails telnet

python 2.x SimpleHTTPServer


rails django telnet top
HTTP

$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

HTTP
[Ctrl+b] [d]

[Ctrl+b] [d] d detach [Ctrl+b]


prefix tmux []
tmux
tmux [detached]
HTTP http://localhost:8000

[Ctrl+b] Emacs Vim


Emacs Vim
tmux

tmux

128

Mac

attach

$ tmux attach-session -t <>

$ tmux attach -t <>

$ tmux a -t <>

dev

$ tmux a -t dev

-t

$ tmux a

tmux dev
HTTP
ssh

tmux
1. [] d
2. edit $ tmux new -s edit
3. edit [] d
4. telnet $ tmux new -s telnet
5. telnet [] d

$ tmux list-sessions

$ tmux ls

tmux

129

Mac

dev: 1 windows (created Tue Jun 10 15:10:32 2014) [80x24]


edit: 1 windows (created Tue Jun 10 16:26:20 2014) [80x24]
telnet: 1 windows (created Tue Jun 10 16:26:53 2014) [80x24]

-t
failed to connect to server
tmux

/
tmux Window

tmux tmux
tmux (Window)0
~/Documents
0

-n

$ tmux new -n <>

tmux

130

Mac

-n -s demo worldcup

$ tmux new -s demo -n worldcup

[] oh-my-zsh

[] c

c create

previous [] p next [] n

[] 0-9
0-9

[] w

tmux

131

Mac

[] ,

tmux

132

Mac

[] &
Shift
y n

tmux

133

Mac

tmux

tmux panetmux

tmux
a
a
a
b
b
c
b
c
d
d
e

tmux

134

Mac

[] %

[] "

tmux

135

Mac

[] o

[]

tmux
1. even-horizontal
2. even-vertical
3. main-horizontal
4. main-vertical
5. tiled

[]
tmux

136

Mac

tmux tmux command

tmux

137

Mac

Git and Github


Git ?

$ brew install git

gti

$ git --version

$ which git /usr/local/bin/git .


Git GitHub

$ git config --global user.name "Your Name Here"


$ git config --global user.email "your_email@youremail.com"

~/.gitconfig .
HTTPS SSH Github

$ git config --global credential.helper osxkeychain

SSH .

Git

138

Mac

Git Ignore
~/.gitignore git

# Folder view configuration files


.DS_Store
Desktop.ini
# Thumbnail cache files
._*
Thumbs.db
# Files that might appear on external disks
.Spotlight-V100
.Trashes
# Compiled Python files
*.pyc
# Compiled C++ files
*.out
# Application specific files
venv
node_modules
.sass-cache

Git ignore

139

Mac

github ssh proxy | github ssh


proxy-wrapper

cat > $HOME/bin/proxy-wrapper


#!/bin/bash
nc -x127.0.0.1:7080 -X5 $*

$ chmod +x $HOME/bin/proxy-wrapper

.ssh/config , github.com

Host github github.com


Hostname github.com
User git
ProxyCommand $HOME/bin/proxy-wrapper '%h %p'

ssh

$ git clone git@github.com:jjrdn/node-open.git

git Using GIT through a SOCKS proxy.

Git
Using GIT through a SOCKS proxy
ssh

140

Mac

Mac dotfiles
dotfilesdotfiles :
dotfiles. (dot) prefix Mac OS X Linux *nixbased

dotfiles

dotfilesfork Holman's dotfilesfork


dotfiles
dotfiles GitHub does dotfiles

Quick Start
OS X
Xcode
dotfiles

How To Use
dotfiles
OS X
Mackup

Quick Start
Erase and reinstall OS X
Mac OS X

Install Xcode
1. App Store
2. Xcode
3. TerminalXcode Command Line Tools:
xcode- select --install

Install dotfiles
git clone $HOME .dotfiles :

git clone https://github.com/amowu/dotfiles.git ~ /.dotfiles

Dotfiles

141

Mac

.dotfiles :

cd ~ /.dotfiles

dotfiles:

script/bootstrap

bootstrap.sh :

1. Homebrew
2. Oh My Zsh
3. dotfiles( .zshrc , .vimrc , .gitconfig , .gitignore , ...)
4. brew packages(binaries, fonts, apps)
5. Mac OS X defaults settings
App Store (Dash, Moom, ...)

Restore backup
Mackup :

mackup restore

Mackup?

How To Use
dotfiles
~/.dotfiles/script/bootstrap *.symlink ln $HOME
:
topic*.symlink.dotfiles
git gitconfig.symlink ~/.gitconfig
gitignore.symlink ~/.gitignore
mackup mackup.cfg.symlink ~/.mackup.cfg
vim vimrc.symlink ~/.vimrc
zsh zshrc.symlink ~/.zshrc

Topical

Dotfiles

142

Mac

"Java"dotfiles
java .zsh shell
.symlink script/bootstrap $HOME .

Components
:
bin/ : bin/ shell
topic/*.zsh : .zsh shell
topic/path.zsh : path.zsh shell $PATH
topic/*.symlink : *.symlink $HOME
symlink script/bootstrap
Holman's dotfiles:
Shell Oh My Zshzsh
topic/aliases.zshtopic/completion.zsh Oh My Zsh[plugins]
(https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins )
zsh/prompt.zshzsh/window.zsh.zsh Oh My Zsh[themes]
(https://github.com/robbyrussell/oh-my-zsh/wiki/Themes )
dotfiles topic/*.symlinktopic/path.zsh

OS X
bin/dot script/bootstrap dotfilesOS X

dot :
1. $HOME/.dotfiles/homebrew/install.sh - Homebrew packages
2. $HOME/.dotfiles/osx/set-defaults.sh - OS X defaults setting

Homebrew packages
homebrew/install.sh Homebrew Homebrew Cask binaryfont app
packages:

binaries=(
git
tree
...
)

font-XXX brew cask search /font-XXX/

fonts=(
font-roboto
...
)

brew cask search XXX Cask Search

apps=(

Dotfiles

143

Mac

dropbox
google-chrome
...
)

packages:
Binary
grc log
mackup
tree
Font
font-roboto Roboto
App
alfred
dropbox
google-chrome Google
iterm2
mou Markdown
qlcolorcode Quick Look syntax highlighting
qlmarkdown Quick Look Markdown
qlstephen Quick Look
sourcetree Git GUI
sublime-text3

OS X defaults setting
osx/set-defaults.sh Mac OS X
Mathias's dotfiles
:
setting
resize (Cocoa applications) defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
? defaults write com.apple.LaunchServices LSQuarantine -bool false

Dotfiles

144

Mac

defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true


defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad
TrackpadRightClick -bool true
defaults -currentHost write NSGlobalDomain com.apple.trackpad.threeFingerDragGesture -bool
true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
app expose defaults write com.apple.AppleMultitouchTrackpad
TrackpadThreeFingerVertSwipeGesture -int 0
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerVertSwipeGesture -int 0
defaults write com.apple.dock showAppExposeGestureEnabled -int 1
/ defaults write NSGlobalDomain com.apple.trackpad.scaling -int 3
defaults write NSGlobalDomain com.apple.mouse.scaling -int 3
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
defaults write NSGlobalDomain KeyRepeat -int 0
Finder defaults write com.apple.finder NewWindowTarget -string "PfDe"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
Finder defaults write com.apple.finder ShowStatusBar -bool true
Finder defaults write com.apple.finder ShowPathbar -bool true
Finde Quick Look defaults write com.apple.finder QLEnableTextSelection -bool true
Finder defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
spring loading defaults write NSGlobalDomain com.apple.springing.enabled -bool true
Dock spring loading defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true
spring loading defaults write NSGlobalDomain com.apple.springing.delay -float 0
network volumes .DS_Store defaults write com.apple.desktopservices DSDontWriteNetworkStores bool true
Dotfiles

145

Mac

column view Finder defaults write com.apple.finder FXPreferredViewStyle -string "clmv"


defaults write com.apple.finder WarnOnEmptyTrash -bool false
Dock defaults write NSGlobalDomain AppleInterfaceStyle Dark
defaults write com.apple.dock mineffect -string "scale"
defaults write com.apple.dock minimize-to-application -bool true
Dock defaults write com.apple.dock show-process-indicators -bool true
Dock defaults write com.apple.dock launchanim -bool false
Mission Control defaults write com.apple.dock expose-animation-duration -float 0.1
Mission Control defaults write com.apple.dock expose-group-by-app -bool false
Dashboard defaults write com.apple.dashboard mcx-disabled -bool true
Dashboard defaults write com.apple.dock dashboard-in-overlay -bool true
Dock defaults write com.apple.dock autohide -bool true
Dock defaults write com.apple.dock autohide-delay -float 0
Dock / defaults write com.apple.dock autohide-time-modifier -float 0
Dock defaults write com.apple.dock showhidden -bool true
homebrew/install.sh osx/set-defaults.sh :

dot

packages defaults setting

Mackup
.zsrc .vimrc dotfile
SublimepluginiTerm2settingOh My ZshpluginSSH
keydotfilesGitHub Mackup
brew install mackup :

mackup backup

Dropbox Google Drive:

mackup restore

ln
~/.mackup.cfg .dofiles/mackup/mackup.cfg.symlink :
Dotfiles

146

Mac

[storage]
engine = dropbox #dropboxgoogle_drive
directory = Mackup #~/Dropbox/Mackup
#
[applications_to_sync]
iterm2
oh-my-zsh
sublime-text-3
ssh
[applications_to_ignore]
#

:
app
iterm2
moom
oh-my-zsh ZSH
sourcetree Git GUI
sublime-text-3
ssh SSH Key
mackup

Hacker's Guide to Setting up Your Mac


First steps with Mac OS X as a Developer

Dotfiles

147

Mac

Sublime Text
Sublime Text Not IDE

GitHub Atom Sublime Text Node.js Chromium


Atom

Sublime Text 3 Sublime Text


3
iTerm2sublshellsubl

$ ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

-Sublime Text

148

Mac

Sublime Text JSON Default


User Default Default User

{
"color_scheme": "Packages/Theme - Spacegray/base16-ocean.dark.tmTheme",
"enable_tab_scrolling": false,
"ignored_packages":
[
"RestructuredText",
"Markdown",
"Vintage"
],
"spacegray_sidebar_font_large": true,
"spacegray_sidebar_font_normal": true,
"spacegray_sidebar_font_small": true,
"spacegray_sidebar_font_xlarge": true,
"spacegray_sidebar_tree_large": true,
"spacegray_sidebar_tree_normal": true,
"spacegray_sidebar_tree_small": true,
"spacegray_sidebar_tree_xlarge": true,
"spacegray_sidebar_tree_xsmall": true,
"spacegray_tabs_auto_width": true,
"spacegray_tabs_font_large": true,
"spacegray_tabs_font_normal": true,
"spacegray_tabs_font_small": true,
"spacegray_tabs_font_xlarge": true,
"spacegray_tabs_large": true,
"spacegray_tabs_normal": true,
"spacegray_tabs_small": true,
"spacegray_tabs_xlarge": true,
"theme": "Spacegray.sublime-theme"
}

149

Mac

Packages
Install Package Control
Sublime Package Control
Sublime Text `ctrl + ``

import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.su

Package Control cmd + shift + p PC Package Control

Packages

150

Mac

Alignment:
TrailingSpaces:
GitGutter: Git
SideBarEnhancements : Sublime Text 3
DocBlockr:
Emmet: HTML/CSS
HTML5: HTML5
GoSublime (optional): Golang
Git
Jekyll
BracketHighlighterhtml

SublimeLinter
SideBarFolders
TableEditorMarkdown

ctrl + shift + p Table Editor: Enable for current syntax or Table Editor: Enable for current
view or "Table Editor: Set table syntax ... for current view" tab ~
ConvertToUTF8
MarkDown EditingMarkdownGithub Favored Markdown3
MarkdownPreview CTRL + B HTML [TOC]
OmniMarkupPreviwer MarkdownPreview F5

Ctrl+Alt+O : Preview Markup in Browser.


Ctrl+Alt+X : Export Markup as HTML.
Ctrl+Alt+C : Copy Markup as HTML.

151

Mac

SublimeLinter Settings
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "none",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"pep8": {
"@disable": false,
"args": [],
"disable": "",
"enable": "",
"excludes": [],
"ignore": "",
"max-line-length": null,
"rcfile": "",
"select": ""
}
},
"mark_style": "outline",
"no_column_highlights_line": false,
"paths": {
"linux": [],
"osx": [
"/usr/local/bin/"
],
"windows": []
},
"python_paths": {
"linux": [],
"osx": [
"/usr/local/bin/"
],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"html (django)": "html",
"html (rails)": "html",
"html 5": "html",
"php": "html",
"python django": "python"
},
"warning_color": "DDB700",
"wrap_find": true
}
}

SublimeLinter

152

Mac

Ctrl+Shift+P
Ctrl+P
Ctrl+G
Ctrl+W
Ctrl+Shift+W
Ctrl+Shift+V
Ctrl+D
Ctrl+L
Ctrl+Shift+L
Ctrl+Shift+Enter
Ctrl+X
Ctrl+M
Ctrl+U
Ctrl+J
Ctrl+F
Ctrl+Shift+F
Ctrl+H
Ctrl+R method
Ctrl+N
Ctrl+K+B
Ctrl+Shift+M
Ctrl+F2/
Ctrl+/
Ctrl+Shift+/
Ctrl+Alt+/Focus
Ctrl+Shift+A
F11
Shift+F11
Alt+F3
Alt+.
Alt+Shift+
Alt+N
Shift+
Tab
Ctrl
Ctrl+Shift+

Ctrl+D
Alt+F3

Ctrl+L Shift+
Ctrl+Shift+L
Ctrl+Shift+M

153

Mac

Ctrl+M
Ctrl+Enter
Ctrl+Shift+Enter
Ctrl+Shift+[
Ctrl+Shift+]
Ctrl+K+0
Ctrl+
Ctrl+
shift+
shift+
Shift+
Shift+
Ctrl+Shift+
Ctrl+Shift+
Ctrl+Shift+
Ctrl+Shift+
Ctrl+Alt+
Ctrl+Alt+

Ctrl+J CSS
Ctrl+Shift+D
Tab
Shift+Tab
Ctrl+K+K
Ctrl+Shift+K
Ctrl+/
Ctrl+Shift+/

154

Mac

Ctrl+K+U
Ctrl+K+L
Ctrl+Z
Ctrl+Y
Ctrl+U Gtrl+Z
Ctrl+F2
Ctrl+T
F6

Ctrl+F
Ctrl+shift+F sublime
Ctrl+P 12@
34#
Ctrl+G
Ctrl+R @
Ctrl+ #
Ctrl+Shift+P sublime textpackage

Esc

Ctrl+Tab
Ctrl+PageDown
Ctrl+PageUp
Alt+Shift+1 1
Alt+Shift+2 -2
Alt+Shift+3 -3
Alt+Shift+4 -4
Alt+Shift+5 4

155

Mac

Alt+Shift+8 -2
Alt+Shift+9 -3
Ctrl+K+B /
F11
Shift+F11

156

Mac

Atom

Atom

TextMateEmacsVim

AtomAtom
Atom

Web

Web

Node.jsAPIJavaScript

JavaScriptC ++
OnigurumaTextMate
NaClEsprima
APIAPI

Atom
polyfills
flexbox

UIWeb

-Atom

157

Mac

GitHubAtomGitHub
EmacsVim

https://github.com/atom

Atom
AtomMacWindowsLinux
Atom
Atomhttps://atom.io
1-1

atom.io

Mac
Macatom.ioAtom
https://github.com/atom/atom/releases/latest
atom-mac.zip
Atom
-Atom

158

Mac

Shell APM

Windows
Windowshttps://atom.io
https://github.com/atom/atom/releases/latest

Atom APM PATH
Atom

Windows
.ZIP AtomWindows
https://github.com/atom/atom/releases

Linux
AtomLinuxDebianRPMAtomatom.ioAtom
https://github.com/atom/atom/releases
DebianDebian dpkg -i

$ sudodpkg -iamd64.deb

-Atom

159

Mac

RedHatRPM -i

$-i atom.x86_64.rpm

Atom
MacWindowsLinuxFreeBSDhttps://github.com/atom/atom/tree/master/docs/buildinstructions

Atom

Atom
Atom

-Atom

160

Mac

Atom

Atom CMD-P

CMD-P Mac

CMDP

-Atom

161

Mac

Atom


CMD-

Atom4UI8

-Atom

162

Mac

UIUI

Atom.io??????

-Atom

163

Mac

80
80

mainlined

-Atom

164

Mac

>> CMD-O

AtomShell
Atom

$-h
v0.152.0
[] [...]

Atom

...

-Atom

165

Mac

[]

>> CMD-S CMD-S



CTL-S Atom

;
>>Atom>>
... CMD-O
./hopes ./dreams

CMD- \ CTRL-0

-Atom

166

Mac

Atom
https://github.com/atom/tree-view
Atom

Atom
CMD-T CMD-P

CMD-B
CMD-B Git
core.ignoredNames finder.ignoredNames

???

minimatch Node.jsglob
minimatchhttps://github.com/isaacs/minimatch
Git core.excludeVcsIgnoredPaths

-Atom

167

Mac

Atom

ATOM
Atom

Git

70
API???

CMD-

atom.ioatom.io

-Atom

168

Mac

Install

AtomAtom

AtomUI

-Atom

169

Mac

atom.io

-Atom

170

Mac

UIMonokai

APM
APM

$ apm help install

APM
AtomAtom>Shell APM
APM
apm install <package_name>

apm install <package_name>@<package_version>

APMemmet@0.1.5 0.1.5
APM APM

$ APM
5
773
5578
Atom.io.coffee.jsmyJavascript.coffee - > myJavascript.js3494
CoffeeScript333618
grep'grep`12249

-Atom

171

Mac

$ apm search coffee


Search Results For 'coffee' (5)
coffee-trace Add smart trace statements to coffee files with one keypress each. (77 downloads, 3 stars)
coffee-navigator Code navigation panel for Coffee Script (557 downloads, 8 stars)
atom-compile-coffee This Atom.io Package compiles .coffee Files on save to .js files. (myJavascript.coffee -> myJavascript.js) (349
coffee-lint CoffeeScript linter (3336 downloads, 18 stars)
git-grep `git grep` in atom editor (1224 downloads, 9 stars)

APM

$ APMgrep
grep
0.7.0
//github.com/mizchi/atom-git-grep
'grep`
1224
9
`APMgrep`

$ apm view git-grep


git-grep
0.7.0
git://github.com/mizchi/atom-git-grep
`git grep` in atom editor
1224 downloads
9 stars
Run `apm install git-grep` to install this package.

Atom

Emacs CTRL-P CTRL-N


CTRL-B CTRL-F

ALT-B ALT-

ALT-F ALT-

CMD- CTRL-E

CMD- CTRL-A

CMD-

-Atom

172

Mac

CMD

CTRL-G

informatively CMD-R
CMD- CMD-Shift-R

-Atom

173

Mac

CTRL-ALT-
ctags CTAGS -R
src /

Mac BREWctags
.ctags home / .ctags
/

CMD-F2
732-7
F2 F2
CTRL-F2

-Atom

174

Mac

Atom


Ctrl-Shift-P

Ctrl-Shift-N

Ctrl-Shift-B

Ctrl-Shift-F

ALT-B ALT-

ALT-F ALT

-Atom

175

Mac

Ctrl-Shift-E CMD

Ctrl-Shift-A CMD

CMD-

CMD-

CMD-A

CMD-L

Ctrl-Shift-W

CTRL-T

CMD-J

CTRL-CMD- CTRL-CMD

CMD--D-

CMD-KCMD-U

-Atom

176

Mac

CMD-KCMD-L

80
editor.preferredLineLength CMD-ALT-Q

Ctrl-Shift-K

CMD-

CMD-FN- Mac
CTRL-K

CMD-

ALT- ALT-H

Alt ALT-D

CMD

CMD--L-

CTRL CTRL-

/
CMD-D

CTRL-CMD-G

-Atom

177

Mac

-Atom

178

Mac

Atom

[]{}XMLHTML
[]{}<>

CTRL-M

CTRL-CMD-M

ALT-CMD-

XML / HTML
/

-Atom

179

Mac

UTF-8
Ctrl-Shift-U

UTF-8UTF-8

Atom
CMD-F

-Atom

180

Mac

CMD-Shift-F

CMD-F CMD-G

CMD-Shift-F

-Atom

181

Mac

glob/
/1 /1 1 // FOLDER2
1

//

habtm has_and_belongs_to_many
HTML HTML
HTMLHTML HTML

<HTML>
<HEAD>
<> </ title>
</ HEAD>
<BODY>
</ body>
</ HTML>

-Atom

182

Mac

<html>
<head>
<title></title>
</head>
<body>
</body>
</html>

-
HTML
ALT-S

/ .atom snippets.cson
>
/ .atom / JSON CSON

.source.js'

-Atom

183

Mac

'console.log'
'' ''
'' 'console.log$ {1}; $ 2'

'.source.js':
'console.log':
'prefix': 'log'
'body': 'console.log(${1:"crash"});$2'

Java Java
source.java CSS

JavaScript

console.log("crash");

-Atom

184

Mac

Tab ;

.source.js '

'' 'ieie

$ {1}{
2
}$ {3}{
4
}{
5
}

'.source.js':
'if, else if, else':
'prefix': 'ieie'
'body': """
if (${1:true}) {
$2
} else if (${3:false}) {
$4
} else {
$5
}
"""

.source.js'
''
'' ''

'.source.js':
'Snippet Name':
'prefix': 'hello'
'body': 'Hello World!'

autocompleter CTRL

-Atom

185

Mac

autocompleter

??????
/

ALT-CMD- [ ALT-CMD]

-Atom

186

Mac

ALT-CMD-SHIFT- { ALT-CMD-SHIFT-} CMD-K CMD-N


N
CTRL-ALT-CMD-F

CMD-K
CMD-K CMD

-Atom

187

Mac

CMD-W CMD-W

Java

.md
Atom
miscategorizes Ctrl-Shift-L

-Atom

188

Mac

AtomGitGitHub

HEAD
CMD-ALT-Z
HEAD git
HEAD - <> HEAD - <>

-Atom

189

Mac

GitHEAD
CMD-Z

Git
CMD-T CMD-B
CMD-B git

-Atom

190

Mac

Git
octicon

Gitgit

-Atom

191

Mac

Git
Git

$ git--global core.editor --wait

git5065

AtomGit

Git

diff
git-DIFF

-Atom

192

Mac

Gitdiff
ALT-G ALT-G /

GitHub
GitHub
GitHub -
ALT-G

GitHub
ALT-G B

GitHub
ALT-G

GitHub
ALT-G

GitHubURL
ALT-G

GitHub

-Atom

193

Mac

GitHub

Atom

AsciiDoc
AsciiDoc

GitHubGit
CMD-

Atom

-Atom

194

Mac

text.plainsource.gfmtext.gitsource.asciidoc

CNTL-M

-Atom

195

Mac

HTMLHTML

IMG []

|||
|------------- |------------- |
|||

B
ALT-S

Atom

-Atom

196

Mac

styles.less
/ .atom
Atom>

/ .atom / styles.less

.cursor {
;
}

atom-text-editor.is-focused .cursor {
border-color: pink;
}

DOM

ALT-CMD-I Chrome

-Atom

197

Mac

CSSCSSlesscss.org
CSSstyles.cssCSS

Atom



[]
' '

'atom-text-editor':
'enter': 'editor:newline'
'atom-text-editor[mini] input':
'enter': 'core:confirm'

/ .atom / keymap.cson

-Atom

198

Mac

Atom>
CMD-

config.cson / .atomCoffeeScriptJSONCSON


excludeVcsIgnoredPaths
''
'fontSize 18

'core':
'excludeVcsIgnoredPaths': true
'editor':
'fontSize': 18


Atom>

disabledPackages

excludeVcsIgnoredPaths .gitignore

ignoredNames Atom
PROJECTHOME

nonWordCharacters

fontSize

fontFamily

Atom

CR

EOL \

preferredLineLength 80

-Atom

199

Mac

showInvisibles

showIndentGuide /

showLineNumbers /

softWrap /

softWrapAtPreferredLineLength / preferredLineLength

tabLength 2

fuzzyFinder

ignoredNames

ensureSingleTrailingNewline

removeTrailingWhitespace /

Python

editor.tabLength
editor.softWrap
editor.softWrapAtPreferredLineLength
editor.preferredLineLength
editor.scrollPastEnd
editor.showInvisibles
editor.showIndentGuide
editor.nonWordCharacters
editor.invisibles
editor.autoIndent
editor.normalizeIndentOnPaste

editor.tabLength
editor.softWrap
editor.softWrapAtPreferredLineLength
editor.preferredLineLength
editor.scrollPastEnd
editor.showInvisibles
editor.showIndentGuide
editor.nonWordCharacters
editor.invisibles
editor.autoIndent
editor.normalizeIndentOnPaste

-Atom

200

Mac

Python


''
'softWrap
tabLength 8
.source.gfm

softWrap

-Atom

201

Mac

.source.ruby

tabLength 2
.source.python

tabLength 4

'global': # all languages unless overridden


'editor':
'softWrap': false
'tabLength': 8
'.source.gfm': # markdown overrides
'editor':
'softWrap': true
'.source.ruby': # ruby overrides
'editor':
'tabLength': 2
'.source.python': # python overrides
'editor':
'tabLength': 4

Atom
Atom

Hacking Atom

AtomAPI

-Atom

202

Mac

AtomWeb
WebJavaScriptCSSCoffeeScriptJavascriptCSS
CoffeeScriptJavaScriptCoffeeScript

MyPackageView = './my-package-view
module.exports =
myPackageView
- >
@myPackageView = MyPackageView myPackageViewState
- >
@myPackageView
- >
myPackageViewState@myPackageView

CoffeeScriptJavaScriptCoffeeScript

CoffeeScriptcoffeescript.org
CSSCSS
lesscss.orgCSS

-Atom

203

Mac

Ruby
OS X comes with Ruby installed (Mavericks even gets version 2.0.0, previously it was only 1.8.7), as we don't want to be
messing with core files we're going to use the brilliant rbenv and ruby-build to manage and install our Ruby versions for our
development environment.

$ brew install rbenv ruby-build rbenv-gem-rehash rbenv-default-gems


$ echo 'eval "$(rbenv init -)"' >> ~/Projects/config/env.sh
$ sourcezsh

The package we just installed allow us to install different versions of Ruby and specify which version to use on a per project
basis and globally. This is very useful to keep a consistent development environment if you need to work in a particular
Ruby version.

$ rbenv install 2.1.1


$ rbenv rehash
$ rbenv global 2.1.1

Install bundler. Bundler manages an application's dependencies, kind of like a shopping list of other libraries the application
needs to work.

$ gem install bundler


$ echo 'bundler' >> "$(brew --prefix rbenv)/default-gems"

Skip r-doc generation. If you use Google for finding your Gem documentation like I do you might consider saving a bit of
time when installing gems by skipping the documentation.

$ echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc

Install Jekyll and Kramdown.

$ gem install jekyll


$ gem install kramdown

Install Rails. With Ruby installed and the minimum dependencies ready to go Rails can be installed as a Ruby Gem.

$ gem install rails


$ echo 'rails' >> "~/.rbenv/default-gems"

Ruby

204

Mac

RubyGems
RubyGems, the Ruby package manager, was also installed:

$ which gem

Update to its latest version with:

$ gem update --system

To install a "gem" (Ruby package), run:

$ gem install <gemname>

To install without generating the documentation for each gem (faster):

$ gem install <gemname> --no-document

To see what gems you have installed:

$ gem list

To check if any installed gems are outdated:

$ gem outdated

To update all gems or a particular gem:

$ gem update [<gemname>]

RubyGems keeps old versions of gems, so feel free to do come cleaning after updating:

$ gem cleanup

We mainly use Ruby for the CSS pre-processor Compass, which is built on top of Sass:

$ gem install compass --no-document

RubyGems

205

Mac

Node.js
Install Node.js with Homebrew:

$ brew update
$ brew install node

Node modules are installed locally in the node_modules folder of each project by default, but there are at least two that are
worth installing globally. Those are CoffeeScript and Grunt:

$ npm install -g coffee-script


$ npm install -g grunt-cli

Npm usage
To install a package:

$ npm install <package> # Install locally


$ npm install -g <package> # Install globally

To install a package and save it in your project's package.json file:

$ npm install <package> --save

To see what's installed:

$ npm list # Local


$ npm list -g # Global

To find outdated packages (locally or globally):

$ npm outdated [-g]

To upgrade all or a particular package:

$ npm update [<package>]

To uninstall a package:

$ npm uninstall <package>

Node.js

206

Mac

Node0.60.11Node n nvm
Node

n
n NodeTJ HolowaychukExpress

"no subshells, no profile setup, no convoluted api, just simple"

$ sudo npm install -g n

n node o

$ n
0.10.1
0.10.15
o 0.10.21
0.11.8

0.11.12

$ n 0.11.12
install : 0.11.12
mkdir : /usr/local/n/versions/0.11.12
fetch : http://nodejs.org/dist/v0.11.12/node-v0.11.12-darwin-x64.tar.gz
#### 5.9%

$ n latest

$ n stable

$ n rm 0.10.1

$ n use 0.10.21 some.js

N and NVM

207

Mac

nvm
nvmNode Version Manager n shell

$ curl https://raw.github.com/creationix/nvm/v0.4.0/install.sh | sh

$ wget -qO- https://raw.github.com/creationix/nvm/v0.4.0/install.sh | sh

nvm clone ~/.nvm ~/.bash_profile , ~/.zshrc `~/.profile source


node

$ nvm install 0.10

$ nvm use 0.10

$ nvm ls
.nvm
-> v0.10.24

$ nvm current
v0.10.24

$ nvm run 0.10.24 myApp.js

nvm

$ rm -rf ~/.nvm

Node

N and NVM

208

Mac

https://github.com/creationix/nvm
https://github.com/visionmedia/n

N and NVM

209

Mac

Python
OS X, like Linux, ships with Python already installed. But you don't want to mess with the system Python (some system
tools rely on it, etc.), so we'll install our own version with Homebrew. It will also allow us to get the very latest version of
Python 2.7.
The following command will install Python 2.7 and any dependencies required (it can take a few minutes to build
everything):

$ brew install python

When finished, you should get a summary in the terminal. Running $ which python should output /usr/local/bin/python .
It also installed Pip (and its dependency Setuptools), which is the package manager for Python. Let's upgrade them both:

$ pip install --upgrade setuptools


$ pip install --upgrade pip

Executable scripts from Python packages you install will be put in /usr/local/share/python , we already had this in the
Env.sh file created before. Save the file and open a new terminal to take the new $PATH into account (everytime you open

a terminal, .bash_profile gets loaded).

Python

210

Mac

Pip Usage
Here are a couple Pip commands to get you started. To install a Python package:

$ pip install <package>

To upgrade a package:

$ pip install --upgrade <package>

To see what's installed:

$ pip freeze

To uninstall a package:

$ pip uninstall <package>

Pip

211

Mac

Virtualenv
python
python python
virtualenv python

virtualenv

sudo pip install virtualenv

mkdir myproject
cd myproject
virtualenv myproject_ENV

1. myproject
2.
3. myproject_ENV
myproject myproject_ENV

cd myproject_ENV
source ./bin/activate

1. myproject_ENV
2.

which python
which pip
pip list

deactivate

Virtualenv

212

Mac

Virtualenvwrapper
Virtualenvwrapper ///

sudo pip install virtualenvwrapper

Virtualenvwrapper ~/.bashrc

if [ `id -u` != '0' ]; then


export VIRTUALENV_USE_DISTRIBUTE=1 # <-- Always use pip/distribute
export WORKON_HOME=$HOME/.virtualenvs # <-- Where all virtualenvs will be stored
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
fi

source ~/.bashrc

mkvirtualenv myproject_ENV # myproject_ENV


workon myproject_ENV # myproject_ENV
deactivate #
rmvirtualenv myproject_ENV # myproject_ENV
lsvirtualenv #

showvirtualenv [env] #
rmvirtualenv [env] # deactivate
cpvirtualenv [source] [dest] #
cdvirtualenv [subdir] #
cdsitepackages [subdir] # sitepackages
add2virtualenv [dir] [dir] # pathproject
toggleglobalsitepackages -q # sitepackages

1. virtualenv documentation: https://virtualenv.pypa.io/en/latest/


2. virtualenvwrapper documentation: http://virtualenvwrapper.readthedocs.org/en/latest/

Virtualenv

213

Mac

Virtualenvwrapper

virtualenvOS X uservirtualenv
virtualenv

$ pip install virtualenvwrapper

or

$ sudo pip install virtualenvwrapper

shell(.bashrc.bash_profile.profile)

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

Reload

$ source ~/.bashrc

1.run

workon

2.run

mkvirtualenv temp

virtualenv temp
3.run

Virtualenvwrapper

214

Mac

workon

temp
4.virtualenvrun

deactivate

5.workonworkon+

$ workon
temp1 temp2
$ workon temp1
(temp1)$

6.run

rmvirtualenv temp

Reference
+Python Virtualenv Pythonbrew
+Installation of virtualenvwrapper

Virtualenvwrapper

215

Mac

Java
Java
MacJava
Mac OS X JavaJava1.6
javaeclipseJava

java -version
Java:
http://support.apple.com/kb/DL1572?viewlocale=zh_CN

Java 1.7
Mac OS X JDKjdk-7u51-macosx-x64.dmg

http://www.oracle.com/technetwork/java/javase/downloads/index.html

JAVA_HOME
JavaJAVA_HOMEMac
Java 1.6JAVA_HOME

/usr/libexec/java_home -v 1.6

Java 1.7JAVA_HOME

/usr/libexec/java_home -v 1.7

JAVA_HOMEJAVAJAVA_HOME
'/System'JDKJava
'~/.zshrc''~/.bash_profile'
Java 1.6

export JAVA_HOME=`/usr/libexec/java_home -v 1.6`


export PATH=${JAVA_HOME}/bin:$PATH

Java

216

Mac

Java 1.7

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`


export PATH=${JAVA_HOME}/bin:$PATH

(Extension Libraries)
Java'$JAVA_HOME/lib/ext'jarMac OS XJava'lib/ext'
jar'/Library/Java/Extensions'jarJNI
'~/Library/Java/Extensions'jarJNI
classpathjava

Eclipse

Eclipse'Eclipse IDE for Java EE Developers':

http://www.eclipse.org/downloads/

eclipse'Applications''/Applications/eclipse/'eclipse
eclipse
'~/.zshrc''~/.bash_profile'
export ECLIPSE_HOME=/Applications/eclipse

homebrew-cask
% brew cask alfred link
% brew cask install eclipse-ide
==> Downloading http://download.eclipse.org/technology/epp/downloads/release/kepler/SR1/e
######################################################################## 100.0%
==> Symlinking App 'Eclipse.app' to '/Users/ppyy/Applications/Eclipse.app'
==> Success! eclipse-ide installed to /opt/homebrew-cask/Caskroom/eclipse-ide/4.3.1

'brew cask alfred link'homebrew caskAlfed


'~/.zshrc''~/.bash_profile'
export ECLIPSE_HOME=/opt/homebrew-cask/Caskroom/eclipse-ide/4.3.1/eclipse/

eclipse
eclipseeclipse'$ECLIPSE_HOME/Eclipse.app/Contents/MacOS'
eclipse.iniECLIPSE_HOME'Finder'(Ctrl+)Eclipse
'Show Package Contents'ContentsMacOSeclipse.ini

--launcher.XXMaxPermSize
2048m
...

Java

217

Mac

-vmargs
...
-Xms512m
-Xmx850m
-XX:PermSize=512m
-XX:MaxPermSize=1024m

ant, maven, tomcat, jetty


brew install ant maven tomcat jetty

Java

218

Mac

MySQL
MySQL

$ brew install mysql

MySQL

$ mkdir -p ~/Library/LaunchAgents
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ find /usr/local/Cellar/mysql/ -name "homebrew.mxcl.mysql.plist" -exec cp {} ~/Library/LaunchAgents/ \;
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

MySQL

$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

$ mysql.server start

{start|stop|restart|reload|force-reload|status}

MySql

219

Mac

Latex
MacTex LaTex

1. MacTex
MacTexpkg.

2.

\documentclass[UTF8,nofonts]{ctexart}
\setCJKmainfont{SimSun} % or any font you have.
\setCJKsansfont{SimHei}
\setCJKmonofont{FangSong}
\begin{document}

Some Chinese fonts should be installed in your system (SimSun, SimHei, FangSong, KaiTi)\end{document}

XeLaTex
:

\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{gbsn}
(wiq)
\end{CJK}
hello
\end{document}

LaTex

3. LaTex
, \, , ,

, Tex, % ,, TeX, , .
, /begin /end ,
, \documentclass{article} \begin{document} ,

3.1.

Latex

220

Mac

\documentclass[UTF8,nofonts]{ctexart}
\setCJKmainfont{SimSun} % or any font you have.
\setCJKsansfont{SimHei}
\setCJKmonofont{FangSong}
\title{world!} %
\author{Andrew Liu} %
\date{\today} %
\begin{document}
\maketitle %
hello world
,
\end{document}

3.2.
, \begin{document} end{document} .
article/ctexart ,
\section{}
\subsection{}
\subsubsection{}
\paragraph{}
\subparagraph{}

\begin{document}
\maketitle %
\tableofcontents % ,
,
\section{hello world 1}
how are you
\subsection{hello world1.1}
fine! thank you, and you?
\subsubsection{hello world 1.1.1}
\paragraph{hello world}
is the programming method print
\subparagraph{hello world}
is also something.
\subsection{Hello nanjing1.2}
\paragraph{}
\end{document}

3.3.
AMS-LaTeX amsmath: \usepackage{amsmath}
LaTex:
inline( $...$ )
display( \[ ... \] )

% display, equation
\begin{equaion}

\end{equation}
$E=mc^2$
display

Latex

221

Mac

\[ E=mc^2 \]
display
\begin{equation}
E=mc^2.
\end{equation}

\sqrt{} , \frac{}{} ,

\[ \pm, \times, \div, \cdot, \cap, \cup,


\geq, \leq, \neq, \approx, \equiv, \sum, \prod, \lim, \int \]
% , , , , , , , , , , , , , ,
% \limits\nolimits
$ \sum_{i=1}^n i\quad \prod_{i=1}^n $
$ \sum\limits _{i=1}^n i\quad \prod\limits _{i=1}^n $
\[ \lim_{x\to0}x^2 \quad \int_a^b x^2 dx \]
\[ \lim\nolimits _{x\to0}x^2\quad \int\nolimits_a^b x^2 dx \]

\[ \Bigg(\bigg(\Big(\big((x)\big)\Big)\bigg)\Bigg) \]
\[ \Bigg[\bigg[\Big[\big[[x]\big]\Big]\bigg]\Bigg] \]
\[ \Bigg \{\bigg \{\Big \{\big \{\{x\}\big \}\Big \}\bigg \}\Bigg\} \]
\[ \Bigg\langle\bigg\langle\Big\langle\big\langle\langle x
\rangle\big\rangle\Big\rangle\bigg\rangle\Bigg\rangle \]
\[ \Bigg\lvert\bigg\lvert\Big\lvert\big\lvert\lvert x
\rvert\big\rvert\Big\rvert\bigg\rvert\Bigg\rvert \]
\[ \Bigg\lVert\bigg\lVert\Big\lVert\big\lVert\lVert x
\rVert\big\rVert\Big\rVert\bigg\rVert\Bigg\rVert \]

\[ x_1,x_2,\dots ,x_n\quad 1,2,\cdots ,n\quad


\vdots\quad \ddots \]

\[ \begin{pmatrix} a&b\\c&d \end{pmatrix} \quad \]


\[ \begin{bmatrix} a&b\\c&d \end{bmatrix} \quad \]
\[ \begin{Bmatrix} a&b\\c&d \end{Bmatrix} \quad \]
\[ \begin{vmatrix} a&b\\c&d \end{vmatrix} \quad \]
\[ \begin{Vmatrix} a&b\\c&d \end{Vmatrix} \]

\[ y= \begin{cases}
-x,\quad x\leq 0 \\
x,\quad x>0
\end{cases} \]

3.4.

Latex

222

Mac

Tex, 1.jpg, graphicx\includegraphics

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width = .8\textwidth]{a.jpg} %
\end{document}

\begin{tabular}{|l|c|r|}
\hline
& & \\
\hline
Windows & MikTeX & TexMakerX \\
\hline
Unix/Linux & teTeX & Kile \\
\hline
Mac OS & MacTeX & TeXShop \\
\hline
& TeX Live & TeXworks \\
\hline
\end{tabular}

3.5.
1.5

\usepackage{setspace}
\onehalfspacing

\addtolength{\parskip}{.4em} % 0.4em

4.
LATEX 2
LaTeX
How do I typeset unicode characters with TexShop?
MacTex typeset chinese
MathJax basic tutorial and quick reference

Latex

223

Mac

nginxMySQLphpglibc

VMwareVirtualBoxOSWindows
UbuntuMac

224

Mac

FreeBSD/bhyve xhyve
FreeBSD bhyve (The BSD Hypervisor) 1 FreeBSD 10.0
xhyve bhyve Mac OS X Mac Linux VirtualBox, VMware
Fusion
xhyve 230 KB xhyve xhyve Lightweight
Virtualization on OS X Based on bhyve
Macbook (OS X 10.10.3)
OS X Yosemite 10.10.4 + Xcode 6.3.2.

xhyve Mac Xcode App Store


git xhyverun.sh Tiny Core Linux

$ git clone https://github.com/mist64/xhyve.git


$ cd xhyve
$ make
$ ./xhyverun.sh

Tiny Core Linux xhyve xhyve Ubuntu 14.04 Server

xhyve ubuntu ubuntu ubuntu-14.04.2-serveramd64.iso iso vmlinuz initrd.gz

$ mkdir ubuntu
$ cd ubuntu
$ wget http://releases.ubuntu.com/14.04/ubuntu-14.04.2-server-amd64.iso
$ dd if=/dev/zero bs=2k count=1 of=/tmp/ubuntu.iso
$ dd if=ubuntu-14.04.2-server-amd64.iso bs=2k skip=1 >> /tmp/ubuntu.iso

xhyve

225

Mac

$ hdiutil attach /tmp/ubuntu.iso


$ cp /Volumes/Ubuntu-Server\ 14/install/vmlinuz .
$ cp /Volumes/Ubuntu-Server\ 14/install/initrd.gz .

10GB ubuntu

$ dd if=/dev/zero of=ubuntu.img bs=1g count=10

xhyve ubuntu_install.sh

$ cd ..
$ vi ubuntu_install.sh
#!/bin/sh
KERNEL="ubuntu/vmlinuz"
INITRD="ubuntu/initrd.gz"
CMDLINE="earlyprintk=serial console=ttyS0 acpi=off"
MEM="-m 1G"
#SMP="-c 2"
NET="-s 2:0,virtio-net"
IMG_CD="-s 3,ahci-cd,ubuntu/ubuntu-14.04.2-server-amd64.iso"
IMG_HDD="-s 4,virtio-blk,ubuntu/ubuntu.img"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"
build/xhyve $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD -f kexec,$KERNEL,$INITRD,"$CMDLINE"
$ chmod +x ubuntu_install.sh

sudo

$ ./ubuntu_install.sh
virtio_net: Could not create vmnet interface, permission denied or no entitlement?
$ sudo ./ubuntu_install.sh

xhyve

226

Mac

ubuntu
LVM root swap

Go Back Execute a shell

[!!] Finish the installation



Installation complete
Installation is complete, so it is time to boot into your new system.
Make sure to remove the installation media (CD-ROM, floppies), so
that you boot into the new system rather than restarting the
installation.

<Go Back> <Continue>

Execute a shell IP nc Mac

BusyBox v1.21.1 (Ubuntu 1:1.21.0-1ubuntu1) built-in shell (ash)


Enter 'help' for a list of built-in commands.
~ # cd /target/
/target # sbin/ifconfig
eth0 Link encap:Ethernet HWaddr da:ae:82:16:cf:32
inet addr:192.168.64.3 Bcast:192.168.64.255 Mask:255.255.255.0
inet6 addr: fe80::d8ae:82ff:fe16:cf32/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:24426 errors:0 dropped:0 overruns:0 frame:104
TX packets:13283 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32881668 (32.8 MB) TX bytes:924462 (924.4 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0

xhyve

227

Mac

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0


collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
/target # tar c boot | nc -l -p 9000

Mac

$ cd xhyve/ubuntu
$ nc 192.168.64.3 9000 | tar x

vmlinuz-3.16.0-30-generic initrd.img-3.16.0-30-generic ubuntu


root=/dev/vda1

$ cd ..
$ vi ubuntu_boot.sh
#!/bin/sh
KERNEL="ubuntu/boot/vmlinuz-3.16.0-30-generic"
INITRD="ubuntu/boot/initrd.img-3.16.0-30-generic"
CMDLINE="earlyprintk=serial console=ttyS0 acpi=off root=/dev/vda1 ro"
MEM="-m 1G"
#SMP="-c 2"
NET="-s 2:0,virtio-net"
#IMG_CD="-s 3,ahci-cd,ubuntu/ubuntu-14.04.2-server-amd64.iso"
IMG_HDD="-s 4,virtio-blk,ubuntu/ubuntu.img"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"
build/xhyve $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD -f kexec,$KERNEL,$INITRD,"$CMDLINE"
$ chmod +x ubuntu_boot.sh
$ sudo ./ubuntu_boot.sh

xhyve

228

Mac

xhyve

229

Mac

Vagrant
VagrantRubyVirtualBox
Vagrant

Vagrant
bug

Vagrant
package
Vagrant

Vagrant

230

Mac

Vgrant
VagrantVirtualBoxVMwareAWS
VirtualBoxVagrantVirtualBox

VirtualBox
VirtualBoxOracle
https://www.virtualbox.org/wiki/Downloads/ VirtualBox

Vagrant
Vagrant gem gem

http://www.vagrantup.com/downloads.html VirtualBox

VirtualBoxVagrant
vagrant
$PATH vagrant

Vagrant
VirtualBoxVagrantVMVagrant
BoxBox
Boxvagrantcloud
Vagrant

Mac

D:\DevelopFolder

box
boxzipVagrantVirtualBox.
box:Ubuntu lucid 64 http://files.vagrantup.com/lucid64.box
CentOSDebian
box

box
box

231

Mac

vagrant box add base boxbox

vagrant box add box


base box base box

vagrant box add base http://files.vagrantup.com/lucid64.box


vagrant box add base https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box
vagrant box add base CentOS-6.3-x86_64-minimal.box
vagrant box add "CentOS 6.3 x86_64 minimal" CentOS-6.3-x86_64-minimal.box

D:\DevelopFolder

vagrant box add base lucid64.box

Downloading or copying the box...


Extracting box...te: 47.5M/s, Estimated time remaining: --:--:--)
Successfully added box 'base' with provider 'virtualbox'!

box /Users//.vagrant.d/boxes/ window C:\Users\


\.vagrant.d\boxes\

vagrant box add boxbox

vagrant init

boxbase

vagrant init "CentOS 6.3 x86_64 minimal"

A `Vagrantfile` has been placed in this directory.


You are now ready to `vagrant up` your first virtual environment!
Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.

Vagrantfile

232

Mac

vagrant up

Bringing machine 'default' up with 'virtualbox' provider...


[default] Importing base box 'base'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- /vagrant

ssh

vagrant ssh

Linux lucid64 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 07:31:39 2012 from 10.0.2.2

windowputtyXshell4.
putty
: 127.0.0.1
: 2222
: vagrant
: vagrant

233

Mac

vagrant@lucid64:/vagrant$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/lucid64-root
78G 945M 73G 2% /
none 179M 176K 179M 1% /dev
none 184M 0 184M 0% /dev/shm
none 184M 64K 184M 1% /var/run
none 184M 0 184M 0% /var/lock
none 184M 0 184M 0% /lib/init/rw
none 78G 945M 73G 2% /var/lib/ureadahead/debugfs
/dev/sda1 228M 17M 199M 8% /boot
/vagrant 298G 76G 222G 26% /vagrant

/vagrant D:\DevelopFolder

Vagrantfile
Vagrantfile
SSHVagrantVagrantRubyRubyRuby

1. box
config.vm.box = "base"
Vagrantbox vagrant init Box box
box base VirtualBoxVBoxManageVM
modifyvm VMVirtualBox
VagrantfileVagrantfile

config.vm.provider "virtualbox" do |v|


v.customize ["modifyvm", :id, "--name", "astaxie", "--memory", "512"]
end

VBoxManage modifyvm VM astaxie 512MB


VMVM
1.
Vagranthost-only()
internetHighBridge()VM
VMIP
high

config.vm.network :private_network, ip: "11.11.11.11"

hostonlyIPIP 192.168..
IP 11.11.. IP
1. hostname

234

Mac

hostname Vagrantfile

config.vm.hostname = "go-app"

hostname hostname PuppetChef


hostname
1.
/vagrant

config.vm.synced_folder "/Users/astaxie/data", "/vagrant_data"

1.
config.vm.network :forwarded_port, guest: 80, host: 8080
host8080forward80
nginxGohost http://localhost:8080 Vagrant
VM80nginxhostVMVM
VM
Vagrantfile vagrant reload VMVM

235

Mac

Vgrant
VagrantVagrant

Vagrant
Vagrant
vagrant box add box
vagrant init box
vagrant up
vagrant ssh

Vagrant
vagrant box list

box

$ vagrant box list


base (virtualbox)

vagrant box remove

box

$ vagrant box remove base virtualbox


Removing box 'base' with provider 'virtualbox'...

vagrant destroy

$ vagrant destroy
Are you sure you want to destroy the 'default' VM? [y/N] y
[default] Destroying VM and associated drives...

vagrant halt

$ vagrant halt
[default] Attempting graceful shutdown of VM...

vagrant package

236

Mac

$ vagrant package
[default] Attempting graceful shutdown of VM...
[default] Clearing any previously set forwarded ports...
[default] Creating temporary directory for export...
[default] Exporting VM...
[default] Compressing package to: /Users/astaxie/vagrant/package.box

vagrant plugin

vagrant provision

BoxVagrantChefPuppet
ChefPuppetprovisioningprovisioningVagrant
provisioning"The problem of installing software on a booted system"ChefPuppet
Shell
vagrant provision --provision-with chef
vagrant reload

$ vagrant reload
[default] Attempting graceful shutdown of VM...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Setting hostname...
[default] Mounting shared folders...
[default] -- /vagrant

vagrant resume

$vagrant resume
[default] Resuming suspended VM...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!

vagrant ssh-config

ssh

$vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null

237

Mac

StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "/Users/username/.vagrant.d/insecure_private_key"
IdentitiesOnly yes
LogLevel FATAL

vagrant status

$vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

vagrant suspend

$ vagrant suspend
[default] Saving VM state and suspending execution...

1. webdb
2.
3. API
4.
VagrantVagrntfile
VMDB
Vagrant config.vm.define

Vagrant.configure("2") do |config|
config.vm.define :web do |web|
web.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", "web", "--memory", "512"]
end
web.vm.box = "base"
web.vm.hostname = "web"
web.vm.network :private_network, ip: "11.11.1.1"
end
config.vm.define :db do |db|
db.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", "db", "--memory", "512"]
end
db.vm.box = "base"
db.vm.hostname = "db"

238

Mac

db.vm.network :private_network, ip: "11.11.1.2"


end
end

:web :db VMVM


hostname IP vagrant up

$ vagrant up
Bringing machine 'web' up with 'virtualbox' provider...
Bringing machine 'db' up with 'virtualbox' provider...
[web] Setting the name of the VM...
[web] Clearing any previously set forwarded ports...
[web] Creating shared folders metadata...
[web] Clearing any previously set network interfaces...
[web] Preparing network interfaces based on configuration...
[web] Forwarding ports...
[web] -- 22 => 2222 (adapter 1)
[web] Running any VM customizations...
[web] Booting VM...
[web] Waiting for VM to boot. This can take a few minutes.
[web] VM booted and ready for use!
[web] Setting hostname...
[web] Configuring and enabling network interfaces...
[web] Mounting shared folders...
[web] -- /vagrant
[db] Setting the name of the VM...
[db] Clearing any previously set forwarded ports...
[db] Fixed port collision for 22 => 2222. Now on port 2200.
[db] Creating shared folders metadata...
[db] Clearing any previously set network interfaces...
[db] Preparing network interfaces based on configuration...
[db] Forwarding ports...
[db] -- 22 => 2200 (adapter 1)
[db] Running any VM customizations...
[db] Booting VM...
[db] Waiting for VM to boot. This can take a few minutes.
[db] VM booted and ready for use!
[db] Setting hostname...
[db] Configuring and enabling network interfaces...
[db] Mounting shared folders...
[db] -- /vagrant

vagrant ssh
ssh

$ vagrant ssh web


vagrant@web:~$
$ vagrant ssh db
vagrant@db:~$

sshwebweb
sshweb( vagrant )

$ vagrant ssh web


Linux web 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Welcome to your Vagrant-built virtual machine.
Last login: Thu Aug 8 18:55:44 2013 from 10.0.2.2
vagrant@web:~$ ssh 11.11.1.2

239

Mac

The authenticity of host '11.11.1.2 (11.11.1.2)' can't be established.


RSA key fingerprint is e7:8f:07:57:69:08:6e:fa:82:bc:1c:f6:53:3f:12:9e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '11.11.1.2' (RSA) to the list of known hosts.
vagrant@11.11.1.2's password:
Linux db 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Welcome to your Vagrant-built virtual machine.
Last login: Thu Aug 8 18:58:50 2013 from 10.0.2.2
vagrant@db:~$

240

You might also like