Mac development environment deployment

1. Install Xcode command line tools

xcode-select --install

2. Install Homebrew

Xcode Command Line Tools must be installed before installing Homebrew.

Run the following command in terminal to install homebrew:

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

Next, we need to do one thing so that the startup link (/ usr/local/bin) of the program installed through Homebrew can run directly without writing out the full PATH. Add / usr/local/bin to the $PATH environment variable with the following command:

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

Cmd+T open a new terminal tab and run the following command to make sure brew works properly.

brew doctor

After the installation, Homwbrew will initialize the local / usr/local to git's work tree, and change the directory owner to the current user. In the future, sudo is not required for brew related operations.

2.1 configure brew source

Because of the problem of brew source, it can be modified to domestic coding source.

cd "$(brew --repo)" && git remote set-url origin https://git.coding.net/homebrew/homebrew.git

cd $home && brew update

2.2 brew command

To install a package, you can simply run:

brew install <package_name>

Update Homebrew's package directory on the server side:

brew update

To see if your package needs to be updated:

brew outdated

Update pack:

brew upgrade <package_name>

Homebrew will cache older packages for use when you want to roll back to older versions. But this is a less used case. When you want to clean up the package cache of the old version, you can run:

brew cleanup

View the list of packages you have installed (including version number):

brew list --versions

3. Use homebrew case to install the software

Why use Homebrew to install the software?

  1. The steps are simple, just one line of command.
  2. It is convenient for management, and can be upgraded in batches without checking and updating one by one.

3.1 file preview plug in

Some Plug-in unit It can make the file preview on Mac more effective, such as syntax highlighting, markdown rendering, json preview and so on.

brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json qlprettypatch quicklook-csv  webpquicklook #suspicious-package

3.2 common software

# Development software
brew cask install shadowsocksx-ng 
brew cask install iterm2
brew cask install phpstorm  
brew cask install visual-studio-code    
brew cask install sublime-text  
brew cask install atom  
brew cask install sourcetree    
brew cask install filezilla 
brew cask install sequel-pro 
brew cask install dash  
brew cask install typora 

# Download third party apps
brew cask install sogouinput    
brew cask install qq 
brew cask install iina  
brew cask install dingtalk  
brew cask install alfred    
brew cask install appcleaner    
brew cask install cheatsheet    
brew cask install onedrive  
brew cask install google-chrome     
brew cask install youdaodict    
brew cask install youdaonote    
brew cask install microsoft-office  
brew cask install snipaste  
brew cask install aliwangwang   
brew cask install mos   
brew cask install jietu 
brew cask install neteasemusic  
brew cask install youku 
brew cask install qqmacmgr  
brew cask install qqlive

# Download MAS https://github.com/mas-cli/mas
brew install mas

# Download Mac App Store app

# Apps under my account
mas install 836500024 789066512 409201541  409203825 409183694  724472954 425424353 1153157709  424182884 451108668

mas install 451108668 # qq
mas install 836500024 # wechat
mas install 789066512 # Maipo
mas install 409201541 # Pages 
mas install 409203825 # Numbers
mas install 409183694 # Keynote
mas install 724472954 # Manico
mas install 425424353 # The Unarchiver
mas install 1153157709 # Speedtest to measure network speed
mas install 424182884 # CHM Reader

# After switching cows to MAS, execute the following in iterm
# Cow account
mas install 443987910 972572731 904280696 948079084  453164367 458887729  852320343 1064959555  411643860 1063631769 823528286  955297617 441258766 967805235 1055273043

mas install 443987910 # 1Password
mas install 972572731 # Money Pro
mas install 904280696 # Things
mas install 948079084 # FlashFTP
mas install 453164367 # SystemPal
mas install 458887729 # Translate Tab
mas install 852320343 # Sketch
mas install 954188948 # MWeb
mas install 445189367 # PopClip
# mas install 915542151 # Monity
mas install 1064959555 # NewFileMenu
mas install 411643860 # DaisyDisk disk view occupation
# mas install 975937182 # Fantastical 2 
# mas install   449830122 # HyperDock
# mas install 584653203 # Paw
# mas install 442160773 # Cocoa JSON Editor
mas install 1063631769 # Medis
# mas install 1031280567 # Postico
mas install 823528286 # Folx GO+ 
mas install 955297617 # CodeRunner3 
mas install 441258766 # magnet window management
mas install 967805235 # Paste
mas install 1055273043 # PDF Expert


# Switch to Mindnote account
mas install 1289197285 

3.3 development environment

# php
brew install php
# mysql
brew install mysql@5.7
# nginx
brew install nginx
# dnsmasq
brew install dnsmasq
# composer
brew install composer
# You can also use the following original installation composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
# redis
brew install redis

# Installing laravel
composer global require "laravel/installer"

# Install valet
composer global require laravel/valet   #Make sure the ~ /. composer/vendor/bin directory is in the PATH of the system

# If an error is reported, execute the following command
export PATH="$PATH:$HOME/.composer/vendor/bin"
valet install # Run the valet install command to configure and install Valet and DnsMasq, and register for Valet background random startup.

# Create workspace
mkdir ~/Codes
cd ~/Codes
valet park

# If you encounter an Unable to determine linked PHP. Error, execute the following
brew link --force php@7.1


# Other development package installation
brew install elasticsearch@2.4

echo 'export PATH="/usr/local/opt/elasticsearch@2.4/bin:$PATH"' >> ~/.zshrc    #Add environment variable
/usr/local/Cellar/elasticsearch@2.4/2.4.6/libexec/bin/plugin install mobz/elasticsearch-head   #Install the head plug-in
/usr/local/Cellar/elasticsearch@2.4/2.4.6/libexec/bin/plugin install analysis-kuromoji     #Install Japanese word segmentation
brew services start elasticsearch@2.4    #Launch elastic search 2.4

In addition, you can install it through brew cask launchrocket , to manage service s installed through brew

brew cask install launchrocket

4. iterm2 configuration

ZSH installation can be seen here

# Check zsh version
zsh --version
# Check the default shell expectation of the terminal / bin/zsh
echo $SHELL

Before installing homebrew, check the version of zsh. If the version is newer, don't worry. If the version is older, use brew install zsh.

brew install zsh-completions

Install oh my Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

If you want to use any plug-ins, you need to add them in the ~ /. zshrc file.

subl ~/.zshrc

install font

git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
cd ..
rm -rf fonts

Modify the code at. zshrc.

ZSH_THEME="agnoster"

Hide the previous hostname and add the following code under. zshrc.

prompt_context () { }

Hide the previous user name and add the following code under. zshrc.

DEFAULT_USER="username"

Hide first line

touch ~/.hushlogin
#remove
rm ~/.hushlogin

Plug-in installation

# Zsh autosuggestions auto completion
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# Zsh syntax highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

plugins=(zsh-autosuggestions zsh-syntax-highlighting)

source ~/.zshrc

5. Terminal ss configuration

Configure the subl command, open the file with sublime, or use ~ /. zshrc

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

subl ~/.bash_profile

or

vi ~/.bash_profile

Add the following code under ~ /. Bash_profilefile:

export http_proxy=http://127.0.0.1:1087;
export https_proxy=http://127.0.0.1:1087;

Here is the switch method defined. Enter the method name directly at the terminal to take effect.

function ss_off(){
    unset http_proxy  # If you do not want to set the method, you can delete the configured environment variable by executing these two sentences separately
    unset https_proxy
    echo -e "Agent closed"
}

function ss_on() {
    export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
    export http_proxy="http://127.0.0.1:1087 "ා this is also the port number
    export https_proxy=$http_proxy
    echo -e "Agent opened"
}

Refresh environment

source ~/.bash_profile

open

ss_off

Check whether it is effective

curl ip.cn

Turn off brew updates

Add in. zshrc

export HOMEBREW_NO_AUTO_UPDATE=true

6. Configuration and use of GIT SSH

6.1 set Git's user name and email: (if it is the first time)

git config --global user.name "****"
git config --global user.email "***@**.com"

View configuration information

# View local global user configuration information
git config --global  --list

6.2 generate key

ssh-keygen -t rsa -C "***@**.com"       

6.3 copy the key to github

cat ~/.ssh/id_rsa.pub

6.4 test

ssh -T git@github.com

7. Common software configuration

7.1 SS

Ignore the proxy settings of these hosts and domains in the preferred network interface:

127.0.0.1, localhost, 192.168.0.0/16, 10.0.0.0/8, FE80::/64, ::1, FD00::/8,shop.test,box.test,ccshop.test,account.jetbrains.com

Here, add all the domain names that need to be accessed locally, so that when you start the global, you will not go ss.

7.2 PhpStorm

Create a repository for phpstorm configuration in Github, and then back up and synchronize it using the following methods.

Enter git warehouse address in file - > Settings repository, and then click overwrite remote and local to select synchronization mode.

After setting up synchronization, install common expansion packs:

  • Laravel Plugin
  • Material Theme UI
  • Translation
  • Dash

Keywords: OS X brew git github ElasticSearch

Added by Das Capitolin on Sun, 01 Mar 2020 08:51:58 +0200