Original link: http://www.h5con.cn/macdao/ocds-guide-to-setting-up-mac/blob/master/README.md
Original link: https://juejin.im/entry/58ca60d461ff4b006018aa2f
I think that "an efficient MAC working environment" has the following features:
Automation
Let me give you an example. Install an app manually, need 1) Open the browser, 2) search for the app's name, 3) Open the app website, 4) find the download link and installation method, 5) Download and wait for the download to complete, 6) Install the download file, 7) There may be subsequent installation steps. While automating the installation of an application, only 1) Opens the Terminal tool, 2) typing the installation command, 3) waiting to complete these steps.
Automation can greatly simplify operations and improve efficiency.
Unified
I often pair programming, occasionally encounter shortcut keys are different, commands and other issues. I strongly recommend that, at least in one team, everyone try to use the same shortcut keys, commands, and other environments. (I remember one practice is this, but I have not found the name and source of the practice, please tell)
Enough
Good enough, if the system itself has met my needs, I will not use third-party tools.
Efficiency
Efficiency, everything is for efficiency.
1. OS X
This section describes some of the settings for the operating system itself.
function keys
By default, F1-f12 are special features, such as adjusting the screen brightness. And when you need to type in f1-f12 (such as when using IntelliJ Idea's shortcut), you need to hold down Fn at the same time. This is very inconvenient for developers.
Change the F1-F12 to the standard function key: Select System Preferences
> Keyboard
in the Keyboard
tab Use all F1, F2, etc. keys as standard function keys
.
Full keyboard control
When you close a file in Sublime Text, you may encounter a dialog box like this:
Note that this button is not the same as the Save
other two buttons, its background is blue. This button is called the default button, in addition to the mouse click Trigger, you can also be triggered by the enter.
So the question comes, if you do not want to save, want to click Don‘t Save
, is it only with the mouse click?
This is not the case: Select System Preferences
> Keyboard
, select it in the Shortcuts
tab, All controls
or use the shortcut key ?F7
. After that, this dialog box will look like this:
This Don‘t Save
button has a circle of blue, which means you can trigger it with the spacebar. Not only that, you can also use the Tab
keys to transfer the blue edge to other buttons to achieve full keyboard control.
In addition to All controls
this method, you can also use ??
to choose Don‘t Save
. ??
is to select Delete or do not store in a dialog box that contains a delete or do not store button.
In addition to the above two methods, incredibly there is a way! Just press ?D
! It is said that ?+按钮的大写首字母
the button can be triggered by pressing. But! I pressed ?C
and ?S
want to cancel and save all useless! But ?D
it's really useful! If it's just this, but I've tried my hand again TextEdit, the dialog box that pops up when you close an unsaved file has three buttons Delete
, Cancel
and a Save
. ?D
?C
But it's useless, but! ?S
can be saved! I can't understand it at all! I had almost collapsed, and had to write down the text in a roaring body. If anyone can explain please tell me, must have Xie!
?C
It should not be used because it is bound to a copy function, and ?D
cannot be used because it does so by selecting the Desktop folder from the Open dialog box or from the Storage dialog box.
You can use this dialog box Esc
to perform the Cancel
operation.
Spotlight shortcut keys
The Chinese version of OS X Spotlight shortcut keys are ?Space
. There are some problems with this shortcut:
- JetBrains Ides, such as IntelliJ idea, webstorm, are used
?Space
as shortcuts to automate this most common function. I do not recommend changing the IDE's shortcut keys, and we recommend changing the shortcut keys for Spotlight.
- For MAC without adding Chinese input method, Spotlight's shortcut is
?Space
. This is true of people in English-speaking countries. So I propose to set the Spotlight shortcut keys to ?Space
match them.
Input Method shortcut keys
In general, the shortcut keys for switching input methods are ?Space
. Since I recommend setting the shortcut key for Spotlight ?Space
, I recommend that you set the shortcut key for the switch input method to ?Space
.
Other shortcut keys
Let your hands as many keyboards and shortcuts as possible, use less mouse and touch pad, can greatly improve the efficiency.
MAC keyboard shortcts
Official Apple document. When you're writing code, how do you get the cursor to the beginning of a line, the end of a row, page up, or move the cursor to the left by a shortcut key? are in this document.
MAC keyboard shortcuts for accessibility features
Official Apple document. Enter trigger the Blue bottom button, the Space trigger blue edge button, all from here.
Set Trackpad Tap
By default, pressing the Touchpad is the tap (click). I like to set it up with a tap to tap:
Select System Preferences
> Trackpad
in the Point & Click
tabs tab Tap to click
.
Dictionary
OS X comes with a dictionary (Dictionary). You can practically use three-finger taps in any application to make a realistic definition of the word.
You can also open the Dictionary app to find words.
An English-Chinese dictionary can be added to the Dictionary application.
Dock Position
The default Dock is below the screen. Our screens are usually 16:10,dock at the bottom of the screen and occupy a small vertical space. It is advisable to put the Dock on the left or right.
Change the Caps Lock key to Control
I often use Control
keys, but this key is hard to press in the lower left corner of the keyboard. At the same time I found that I rarely use Caps Lock
keys, I usually use the Shift
key with the letter to enter uppercase letters, or first lowercase and then (through the shortcut key) into uppercase.
For these reasons, I Caps Lock
changed the function of the key into a Control
key. Many of my colleagues have done the same thing, possibly influenced by hhkb.
Setting method: Select System Preferences
> Keyboard
, click the button in the Keyboard
tab, in the Modifier Keys...
popup window, Caps Lock (?) Key:
change the corresponding option ? Control
.
Remove all Dock Icons[ocd]
This article applies to obsessive-compulsive disorder.
By default, the dock is occupied by a bunch of system-brought apps, most of which I rarely use, and when I open several popular apps, there will be a lot of icons on the dock, each of which will be squeezed very small. So I'm going to erase all the pinned icons on the dock, so there's only one app I open on the dock.
The Ps:finder icon is not erased.
In addition to a delete icon, you can also use this command to hide all the fixed icons:
static-only -boolean true; killall Dock
Recovery is also very simple:
delete com.apple.dock static-only; killall Dock
PS: If you use this method, the Dock Downloads
will be hidden.
Reset Launchpad location [OCD]
This article applies to obsessive-compulsive disorder.
When new applications are installed, they often run to the first screen of Launchpad, so their location is related to the order in which they are installed, and I prefer that they be arranged in a more stable order, such as in the default order of the system:
defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
In the default order, the Launchpad first screen is only available in Apple's home app.
Create a case-sensitive workspace
In a multi-person collaborative project development, because the Mac file system by default is case-insensitive, so there are often some strange problems. Create a case-sensitive workspace (workspace) To resolve these issues:
create -type SPARSE -fs ‘Case-sensitive Journaled HFS+‘ -size 100g -volname workspace ~/Documents/workspace.dmg.sparseimage
You can mount the image in three ways:
- Direct double-click to open
~/Documents/workspace.dmg.sparseimage
open ~/Documents/workspace.dmg.sparseimage
hdiutil attach ~/Documents/workspace.dmg.sparseimage
Keychain Access
Keychain Access (Keychain access) is an OS X application, and for me its biggest feature is to view the various accounts and passwords that have been saved, including the Wi-Fi password.
2. Common Tools
This section describes some of the commonly used third-party applications and their settings that are not directly related to development.
Homebrew
Package management tools, officially called The missing package manager for OS X
.
Installation steps are at the official website.
After the brew, to download tools, such as MySQL, Gradle, Maven, node. js and other tools, you do not need to download the Internet, as long as a line of command can be done:
brew install mysql gradle maven node
PS: Apple Command line Tools is automatically downloaded and installed when you install brew.
The alternative to brew is macports, and now it's almost no one.
Homebrew Cask
Brew-cask allows you to install OS X apps using the command line. For example, you can install Chrome like this: brew cask install google-chrome
. Evernote, Skype, Sublime Text, VirtualBox, etc. can all be installed with Brew-cask.
Brew-cask is community-driven, and if you find that the app on Brew-cask is not the latest version, or you're missing an app, you can submit your pull request yourself.
Installation steps are at the official website.
Apps can also be installed through the App Store, and some apps can only be installed through the App Store, such as some Apple apps like Xcode. The App Store does not have a corresponding command-line tool and requires an Apple ID. It's easy to update.
Almost all common applications can be installed via Brew-cask and downloaded from the app's official website, so when you install a new app, it's recommended to install it with Brew-cask. If you don't know the ID of the app in Brew-cask, you can brew cask search
search by command first.
ITerm2
ITerm2 is the most commonly used terminal application and is a replacement for Terminal applications. Provides a Split Panes
bunch of practical features such as. Its default black background let me not hesitate to abandon the Terminal.
Installation:
brew cask install iterm2
Thanks to Brew-cask, we can install ITerm2 automatically through the command line.
In the terminal, in addition to the use ?E
of such shortcut keys (see other shortcuts), but also can use ?B
, ?F
such as shortcut keys (for specific reference here). The premise is to set this up:
Select Iterm
menu > Preferences
> Profiles
, select the profile you are using (default is Default
), Keys
Left option (?) key acts as
and set the and both in the tab Right option (?) key acts as
+ESC
.
When I open a new window/tab, the new window is always the HOME directory by default, and I have to go to the working directory every time I tap a command. If you want this new window to automatically enter the working directory when it is opened, the following settings are required:
Select Iterm
menu > Preferences
> Profiles
, select the profile that you are using (default), and select from the General
section in the tab Working Directory
Reuse previous seesion‘s directory
.
At this point, the Terminal application has done its historical mission well. The following command line will be given to ITerm2.
Double-clicking in ITerm2 will automatically select the corresponding word, and three-click will select the corresponding whole line. The selected content is automatically entered into the Clipboard and no more press ?C
copy is required.
Oh My Zsh
The default Bash is black and white with no color. and Oh My Zsh can take you into the color age. Oh My Zsh also provides a set of plugins and tools to simplify command-line operations. We'll see a lot of introductions in the back, and you'll see that I love this guy.
Installation method See official website.
The plugins I currently use are:git z sublime history rbenv bundler rake
Oh My Zsh uses the Z shell (Zsh), a shell similar to bash, not bash.
In the Z shell, ~/.zshrc
It is the most important configuration file. Oh My Zsh writes the current environment when it is installed $PATH
~/.zshrc
. This is not the behavior I expected, because using brew, we basically no longer need to customize $PATH
, and Oh My Zsh provides the default $PATH
value $HOME/bin:/usr/local/bin:$PATH
is very suitable for a value, it is $HOME/bin
added $PATH
, you can let us put our own script $HOME/bin
down.
So it is recommended to reset ~/.zshrc
:
~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
Once submitted on June 17, 2016, zshrc.zsh-template
it is no longer modified $PATH
. Please find # export PATH=$HOME/bin:/usr/local/bin:$PATH
this line and remove the front #
.
Oh My Zsh also has a lot of valuable plugins.
The substitutes have Oh My Fish. Based on Fishshell.
Stow
The GNU Stow is a small public who for managing Symbolic links (symlink). It is mainly used to symlink your dotfiles such as emacs,git,fish/zsh configuration files. installation requires only
brew install stow
After installing the Stow, we can start symlink some dotfiles. The complete process of using Stow and Dotfiles can be consulted http://www.h5con.cn/jcouyang/dotfiles
When your dotfiles is properly symlink ~/dotfiles
, push to GitHub will never be afraid to switch computers.
Git Common aliases
Almost everyone uses some methods, such as Git aliases, to improve efficiency, and almost everybody uses them git st
instead git status
. However, this needs to be set manually, and everyone is not exactly the same.
Oh My Zsh provides a set of system aliases (alias) to achieve the same functionality. For gst
example git status
, as an alias. And the Git plugin is Oh my Zsh is enabled by default, equivalent to you use Oh my Zsh, you have a set of high-efficiency aliases, but also the global universal. Isn't that great? Here are some of my favorite aliases:
Alias |
Command |
Gapa |
git add --patch |
Gc! |
git commit -v --amend |
Gcl |
git clone --recursive |
Gclean |
git reset --hard && git clean -dfx |
Gcm |
git checkout master |
Gcmsg |
git commit -m |
Gco |
git checkout |
Gd |
git diff |
Gdca |
git diff --cached |
Glola |
git log --graph --pretty = format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit --all |
Gp |
git push |
Grbc |
git rebase --continue |
Gst |
git status |
Gup |
git pull --rebase |
Gwip |
git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--" |
For a complete list, please refer to: http://www.h5con.cn/robbyrussell/oh-my-zsh/wiki/Plugin:git
Scroll Reverser
When you're browsing a very long page, you've finished reading the current display and want to see what's next, you can swipe up on the Trackpad, or scroll up the mouse wheel. This is the rolling direction known as "nature".
However, in Windows the mouse scrolling behavior is reversed: the mouse wheel scrolls down to let the browser display subsequent content, scroll up will reach the top of the page. You can modify the System preferences in OS X (select System Preferences
> Trackpad
, uncheck in the Scroll & Zoom
tab Scroll direction: natural
), but this will change the direction of the mouse wheel and the direction of the Trackpad.
To change the direction of the mouse wheel only, while keeping Trackpad is still "natural", we need to Scroll Reverser:
install scroll-reverser
PS: This item will invalidate the three-finger click
Shiftit
Native OS X can only manually resize the window, so we need window management tools. I've used a lot of window management tools, but most of the tools have problems with shortcut key conflicts (mostly IntelliJ idea for me). Shiftit is a rare, non-conflicting window management tool:
brew cask install shiftit
Older versions of Ps:shiftit need to have X11 installed, and the latest version has fixed the issue.
Substitutes have Sizeup, the main shortcuts and shiftit are the same.
Of course, if you like Hacking,slate is a good hackable window management tool. Configuration can refer to http://thume.ca/howto/2012/11/19/using-slate/
Sublime Text 2
Installation:
install sublime-text
Specifying the use of Sublime Text to open a file on the command line is a very common feature, and we will typically add links as described in OS X command lines ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
subl
. But if you install with Brew-cask, congratulations, you don't need to run this command, because Brew-cask automatically helps you do this thing. And when you unload Sublime Text, Brew-cask will automatically delete this link.
At the same time Oh My Zsh also provides the Sublime Text plugin, called sublime
. Reference: Http://www.h5con.cn/robbyrussell/oh-my-zsh/tree/master/plugins/sublime, this plugin is perfectly compatible with the sublime Text installed by Brew-cask.
Substitutes are Atom, TextMate, Sublime text 3, and so on, like Sublime text 2, the command line tool will be automatically added with the Brew-cask installation $PATH
.
Macdown
Macdown is the Markdown editor. Since the Mou has not supported the code highlighting, I turned to Macdown. Perfect support for GFM.
I especially like Markdown, I use Makdown to write articles (including this article), write Slides (reveal.js). Markdown allows me to focus on the content itself without having to devote myself to typography and styling.
Installation:
brew cask install macdown
Z
After opening the terminal, how do you enter the working directory of the project? Yes cd xxx
, ?R
or with an alias?
The Z tool can help you get to the table of contents quickly. For example, running on my Mac z cask
will go into the /usr/local/Library/Taps/caskroom/homebrew-cask/Casks
directory.
The installation of this item is very convenient and does not even need to download anything, because it has been integrated in the Oh My Zsh. Edit the ~/.zshrc
file, plugins=(git)
add it to the z
line plugins=(git z)
, and then run source ~/.zshrc
reload the configuration file to use Z.
Substitutes are autojump. AutoJump need to use a brew installation.
Vimium
Vimium is a Google Chrome extension that lets you manipulate chrome on a purely keyboard and turn your chrome into a "hacker's browser".
Please refer to the official website for installation methods.
Other browsers also have similar tools, such as FireFox's keysnail.
LastPass
LastPass is a tool for managing passwords, supports two validations, provides all browser plugins, and MAC desktop versions.
Most importantly, it provides a command-line version that can be installed directly through brew
install lastpass-cli --with-pinentry
After that, you only need to log in:
lpass login [email protected]email.com
You can copy the password or integrate it into other commands:
show --password gmail.com -c
Sourcetree
Sourcetree is an excellent Git graphical client from the Atlassian company. If you find that the command line does not meet your requirements, you can try Sourcetree.
Installation:
brew cask install sourcetree
Installing with Brew-cask will automatically add the command line tool stree
to the $PATH
inside. Typing on the command line stree
allows you to quickly open the current Git repository with Sourcetree. For detailed usage, see stree --help
.
Cheatsheet
Cheatsheet can display the list of shortcut keys for the current program, and the default shortcut is long press ?
.
Installation:
brew cask install cheatsheet
Alfred
Mac users do not have the necessary artifact of the mouse keyboard, with a lot of workflows, habits can greatly reduce the operating time.
Easy to get started, the cost of tuning in the late custom workflows, but there are a large number of Lei Feng users to provide a ready-made extension, visit here to choose like, and can be extremely simple to modify according to their needs.
Installation:
brew cask install alfred
Resources
- Hacker ' s Guide to Setting up Your Mac
- Setting up a new (OS X) Development machine
- Efficient MacBook Working Environment configuration
- How do programmers use their Mac gracefully?
- Decorate your Dock: the appearance of the article
Some basic settings for Mac (share article)