Mac development environment to build

Homebrew

Homebrew is a package installation tool that makes it easier for you to install and update programs, and the default package management tool for os x system is Macports . Macports works in a similar way to Homebrew. It downloads the source code and then compiles it locally. When it is installed, it relies on Compile and install the packages that exist locally (specifically, in the file /opt/local). As for the same thing that does not exist in the system memory, it does not pay attention, which also leads to a problem, which will cause too much redundancy to the system. remaining files. The emergence of Homebrew solves this problem. As long as the system already has a package, then homebrew will not be installed. And homebrew management is also very powerful, all packages are installed under /user/local/ and use Ruby to define package installation configuration (called formula), customization is very simple.

Before installing Homebrew, you need to install Xcode Command Line Tools, so you can use Homebrew compiled based on Xcode Command Line Tools.

1. Xcode Command Line Tools installation

The basis of the development environment of the entire Apple system is Xcode Command Line Tools. Note the difference between this and Xcode. Xcode Command Line Tools is the command set of the development environment, and Xcode is Apple's IDE. Installing one of them does not mean that the other is also used. Install. Execute the following command in Terminal to install Xcode Command Line Tools.

xcode-select --install

2. Homebrew installation

Execute the following command in the terminal

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

/usr/local/binAdd to the $PATHenvironment variable with the following command

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

Execute after the installation is complete brew doctor, if the following is displayed, the installation is successful

    brew doctor encountered a warning

        brew doctor
    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry or file an issue; just ignore this. Thanks!
    Warning: /usr/local/var/homebrew/locks isn't writable.
    Homebrew writes lock files to this location.
    You should change the ownership and permissions of /usr/local/var/homebrew/locks
    back to your user account.

      sudo chown -R $(whoami) /usr/local/var/homebrew/locks


After the installation is complete, Homwbrew will initialize the local /usr/local as the working tree of git, and change the owner of the directory to the currently operating user. In the future, brew related operations do not require sudo.

3. Homebrew common commands

  • brew install [package]:Installation package

  • brew uninstall [package]: uninstall package

  • brew outdated: List outdated software

  • brew upgrade: Update outdated software (all or specified)

  • brew update: Upgrade homebrew's package directory on the server side

  • brew list: list all installed packages

  • brew clean up: clean old version cache

  • brew info: Retrieval of installation package information

brew update is for updating Homebrew, brew upgrade is for updating installed software

4. 利用 Homebrew 安装常用包

  • brew install node

  • brew install python3

  • brew install wget

你也可以输入brew search来寻找需要安装的包,或者在这里查找searchbrew

5. Homebrew Cask

Homebrew Cask可以优雅、简单、快速的安装和管理 OS X 图形界面程序,比如 Google Chrome 和 Dropbox。运行以下命令进行安装

brew tap caskroom/cask  // 添加 Github 上的 caskroom/cask 库

brew install brew-cask  // 安装 brew-cask

推荐安装程序:

brew cask install alfred

brew cask install appcleaner

brew cask install cheatsheet`: 显示当前程序的快捷键列表,默认快捷键是长按command键

同样的你也可以通过输入brew cask search来寻找需要安装的app,或者在这里查找caskroom

iTerm2

iTerm2 是 Mac OS 下一个牛逼的终端。

安装

brew cask install iterm2

常用快捷键

  • command+shif+h:弹出历史记录窗口

  • command+/:高亮当前鼠标位置

  • command+;:自动补全命令

  • command+f:全文查找功能,输入要查找的内容,即可在当前命令行页面查找并高亮显示

  • command+shif+s:保存当前窗口快照

  • command+opt+b:快照回放

设置

iter2配置
打造好用的终端

zsh 和 oh-my-zsh

zsh也是shell的一种,通过输入下面的命令可以查看你的系统中提供了几种shell

cat /etc/shells

显示如下

# List of acceptable shells for chpass(1).

# Ftpd will not allow users to connect who are not using

# one of these shells.


/bin/bash

/bin/csh

/bin/ksh

/bin/sh

/bin/tcsh

/bin/zsh

可见系统中提供了6中shell,OS X默认的shell是bash

使用zsh的理由:使用zsh的9个理由

将zsh设为默认的shell:输入chsh -s /bin/zsh命令,然后重启iTerm2,zsh就已经被配置成默认shell了

oh-my-zsh

安装oh-my-zsh

oh-my-zsh的发布页面oh-my-zsh,安装配置方式都在这上面。我是通过wget进行的安装

wget --no-check-certificate http://install.ohmyz.sh -O - | sh
zsh配置

1.主题配置

zsh的配置几乎都在~/.zshrc下面,用编辑器打开文件,你会看到很多选项,建议你感觉自己的需求进行配置,不懂得可以查询文档。这里我只说一下主题的配置。在~/.oh-my-zsh/themes存在各式各样的主题文件,每个主题的样子你可以通过这个网址进行查看,选好样式后,在.zshrc中的ZSH_THEME设置成你所选用的主题。重启iTerm2,便可以看到相应的效果。这里要注意不要使用Mac默认编辑器打开.zshrc进行编辑,最好使用你自己平常使用的编辑器如sublime text,不然容易出现错误,因为Mac自带的编辑器在保存时引号会自动识别成中文式的,输入以下命令便可通过Sublime text打开配置文件。

open ~/.zshrc -a /Applications/Sublime\ Text.app

2.插件配置及使用

  参考:https://segmentfault.com/a/1190000005013881


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324505013&siteId=291194637