markdown Mac设置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Mac设置相关的知识,希望对你有一定的参考价值。

# Mac Setup Distilled

## Install common command line apps

Starting from a clean install

### Install HomeBrew

From your terminal
- Install homebrew:

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

> Note: brew needs Xcode Command Line Tools to be compiled so you may see the following request:

```
==> The Xcode Command Line Tools will be installed.

Press RETURN to continue or any other key to abort
```

### Install node, git, postgres and mongo

From your terminal
- brew install the following:
```sh
brew install node
brew install git
brew install postgres
brew install mongo 
```

#### Config Git

Setup git username and email address

- In Terminal,

```sh
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
```
  
##### Get: Use git osxkeychain helper

The credential helper tells Git to remember your GitHub username and password. If you installed Git using Brew then the credential helper is already installed installed.

- In Terminal,

```sh
git config --global credential.helper osxkeychain
```

Now you can use HTTPS for git instead of SSH.

### Install global NPM packages

Install common global NPM packages 
- brew install the following:

```sh
npm install -g eslint mocha http-server nodemon
```

### Configure a global ESLint

ESLint supports both global and local configurations so you can have eslintrc files in individual projects as well as at user root. The child configurations in the project folder take precedence over higher configurations. In your user root create the following file.
- From your terminal:
  - cd to user root `cd ~`
  - touch `eslintrc.json`
  - add the following to the file

```js
/** 
* ESLint: http://eslint.org/docs/user-guide/configuring
*/
{
	// https://eslint.org/docs/user-guide/configuring#specifying-parser
    "parserOptions": {
       "ecmaVersion": 7  //same as 2016
    },
    
    // https://eslint.org/docs/user-guide/configuring#specifying-environments
    "env": {
        "browser": true,
        "node": true,
        "es6": true,
        "mocha": true,
        "jest": true,
        "mongo": true,
        "jquery": true
    },

    // our configuration extends the recommended base configuration
    // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
    "extends": "eslint:recommended",

	// https://eslint.org/docs/rules/
    // ESLint rules: Severity Levels: off = 0 | warn = 1 | error = 2
    "rules": {
        "strict": ["error", "safe"],   	//prefer `'use-strict';` pragma
        "eqeqeq": [2, "allow-null"],
        "no-console": "off",          	//ignores `console.log()`
        "no-unused-vars": ["warn", { "vars": "local", "args": "after-used", "ignoreRestSiblings": false }],
        "no-eval": "error",            	//disallows `eval()` usage
        "quotes": [2, "single", "avoid-escape"], //prefer single quotes over double quotes
        "indent": ["error", 2, {		// enforce 2 space indents (not tabs)
        	"SwitchCase": 1				// clauses with 2 spaces with respect to switch statements
        }],
        "semi": ["error", "always"]    //enforce semi-colon usage
    }
}
```

### Configure Postgres PGDATA

Set the default PostgreSQL PGDATA directory
- Add the following to your `~/.bash_profile` file

```sh
touch ~/.bash_profile
echo 'export PGDATA=/usr/local/var/postgres' >> ~/.bash_profile
```

### Install Development Apps

- Install [Visual Studio Code](https://code.visualstudio.com/download)
- Recommended Extensions:
  - ESLint
  - Git History
  - Git Lens
  - vscode-icons
  - npm
  - npm intellisense
- Postgres GUIs
  - [DBeaver](https://dbeaver.jkiss.org/) - Universal, works on Mac, Win and Linux
  - [PSequel](http://www.psequel.com/)
  - [Postico](https://eggerapps.at/postico/)
- Mongo GUIs
  - [MongoBooster](https://mongobooster.com/)
  - [RoboMongo](https://robomongo.org/)

App Store Apps:
- Better Snap tool or Magnet  ($)
- Chrome
- Chrome Extensions
  - JSON Viewer
  - AdBlock
  - Open Frame
  - Thinkful
- Chrome Canary
- Postman
- Slack 
- System Monitor ($)

Other Apps
- Dropbox
- Google Drive

## Optional Installs and Configs

### OPTIONAL: Create a global gitignore

Git uses both local and global gitignore files. You can setup a global gitignore which will prevent common files from accidentally being committed to your repos.

- From your terminal:
  - cd to user root `cd ~`
  - touch `.gitignore`
  - add the following configuration

```txt
######################
# REF: https://gist.github.com/octocat/9257657
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
 
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
 
# Logs and databases #
######################
*.log
# *.sql This should be committed for demos
*.sqlite
 
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
```

### OPTIONAL: Configure command line completion
If you installed the above apps using brew, then you can setup command line completion for git, npm, brew, 

```sh
#####
# (OPTIONAL) COMMAND LINE COMPLETION
# http://superuser.com/questions/31744/how-to-get-git-completion-bash-to-work-on-mac-os-x
#####
# Load bash completion for brew
if [ -f `brew --prefix`/etc/bash_completion.d/brew ]; then
    source `brew --prefix`/etc/bash_completion.d/brew
fi

# Load bash completion for git
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
	source `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi

# Load bash completion for NPM
if [ -f `brew --prefix`/etc/bash_completion.d/npm ]; then
    source `brew --prefix`/etc/bash_completion.d/npm
fi

```

### OPTIONAL: Configure Git Prompt

Optionally, you can setup your prompt to show your git repository status

```sh
#####
# (OPTIONAL) GIT PROMPT SUPPORT 
# View the git-prompt.sh file for mor information
#####
# Load git prompt
if [ -f `brew --prefix`/etc/bash_completion.d/git-prompt.sh ]; then
    source `brew --prefix`/etc/bash_completion.d/git-prompt.sh
    PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
fi
```

Now you command prompt will looks something like this:
  ```sh
  [user@MACHINE git-repository-name (master)]$ 
  ```

### OPTIONAL: Terminal Config

Open Terminal App and open preferences

- On the "General" tab under "New window with profile", select "Homebrew"
- On the "Profiles" tab, highlight "Homebrew" and choose default (at bottom of list)


### OPTIONAL: Chrome Configs

Disable swipe to go back
```sh
defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE
```

### OPTIONAL: Show Hidden Files

```sh
defaults write com.apple.finder AppleShowAllFiles YES
```
> To hide them again, run `... AppleShowAllFiles NO`

### OPTIONAL: Change Dock Slide Out

 - Make dock slide-out very, very slowly so it doesn't get in the way

```sh
defaults write com.apple.dock autohide-delay -int 5; killall Dock;
```

 - Make dock slide-out instantly, if you like that kinda thing?!

```sh
defaults write com.apple.dock autohide-delay -int 0;
defaults write com.apple.dock autohide-time-modifier -int 0;
killall Dock;
```
- Restore dock defaults

```sh 
defaults delete com.apple.dock autohide-delay;
defaults delete com.apple.dock autohide-time-modifier;
killall Dock;
```

以上是关于markdown Mac设置的主要内容,如果未能解决你的问题,请参考以下文章

markdown 有用的Mac升级/设置

markdown Mac OS X设置。

markdown Mac设置

markdown 系统设置新mac的东西

markdown 在Mac上设置Android开发环境

markdown 在Mac上轻松设置Android开发环境