Tao He

Tao He

  • Docs
  • API
  • Help
  • Blog

›Recent Posts

Recent Posts

  • Microsoft PowerPoint
  • Chrome
  • Alfred
  • Docusaurus
  • Git Commands

macOS

November 15, 2013

{% include JB/setup %}

Overview

https://github.com/nikitavoloboev/my-mac-os

https://github.com/nikitavoloboev/my-ios

System

Set the key repeat rate

defaults write -g InitialKeyRepeat -int 10  # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1  # normal minimum is 2 (30 ms)

Turn on "three finger drag" for your Force Touch trackpad

XCode

If encountered this error:

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Run

xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

homebrew

brew update
brew install
brew uninstall

doctor

brew doctor

Path

Source code in /Library/Caches/Homebrew/

Formula in /usr/local/Library/Formula/

cask

brew cask install google-chrome

Add to ~/.zshrc

plugins=(brew-cask)

git

Install git

brew install git
brew install tig
brew tap mkchoi212/fac https://github.com/mkchoi212/fac.git
brew install fac  # Easy-to-use CUI for fixing git conflicts

If encountered error:

sudo xcodebuild -license

Then 'agree' to it.

gperftools

Install

brew install gperftools

fd

fd is a simple, fast and user-friendly alternative to find.

Install

brew install fd

Usage

fd blahblahblah

The Silver Searcher

Install

brew install the_silver_searcher

Usage

ag blahblahblah ~/code

Python

Python

Emacs

brew tap d12frosted/emacs-plus
brew install emacs-plus --with-modern-icon
ln -s /usr/local/opt/emacs-plus/Emacs.app /Applications

Neovim

pip2 install neovim
pip3 install neovim
brew update
brew reinstall neovim
which nvim
nvim --version

In nvim, run :CheckHealth. It checks for common problems and best practices.

vim

brew cask install xquartz
brew options vim
brew install vim --with-client-server --with-gettext --with-luajit --with-python3
brew options macvim
brew install macvim --with-luajit --override-system-vim
which vim
vim --version
which mvim
mvim --version

iTerm

Color

Prefs... -> Profiles -> Terminal -> Terminal Emulation

Report Terminal Type: xterm-256color

Download solarized

Install iterm2-colors-solarized/Solarized\ Dark.itermcolors

Prefs... -> Profiles -> Colors -> Load Presets...

Key

Prefs... -> Profiles -> Terminal -> Check Use modern parser

If <C-h> does not work in neovim, try this.

Method 1

Add these line to ~/.zshrc

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
tic $TERM.ti

Method 2 (Incompatible with Vim. Not Recommended)

Prefs... -> Profiles -> Keys -> +

KeybindingDescription
^h[104;5u
^i[105;5u
^m[109;5u

https://github.com/neovim/neovim/issues/2048

fooCoder的iTerm2使用之道

guake

System Prefs... -> Shortcuts -> Mission Control -> Uncheck Show Dashboard

Prefs... -> Keys -> Check Show/hide system-wide hotkey -> F12 -> Check Hotkey profile

Shell Integration

Prefs... -> Profiles -> Terminal -> Check Use modern parser

tmux

Install tmux

brew options tmux
brew install tmux --with-utf8proc

Add to ~/.zshrc

plugins=(tmux)
export DISABLE_AUTO_TITLE=true

Lists out every bound key and the tmux command it runs

tmux list-keys

Default prefix is control + b.

Create a new tmux session

tmux [-CC] [-2] new -s session name

List tmux sessions

tmux list-sessions

In iTerm: iTrem -> Shell -> tmux -> Dashboard

Attach to a session

tmux [-CC] [-2] attach -t session name

Detach

prefix + d

In iTerm: iTrem -> Shell -> tmux -> Detach

Create a new window

prefix + c

In iTerm: iTrem -> Shell -> tmux -> Window or iTrem -> Shell -> tmux -> Tab

Move to the window based on index

prefix + 0-9

In iTerm: command + 0-9

Rename window

prefix + ,

Splits the window into two vertical panes

prefix + "

Splits the window into two horizontal panes

prefix + %

Using -CC will integrate tmux into iTerm2 UI. Such as split window and tab. Each tab corresponding to a window in the tmux session. iTerm2 use an arrow icon to indicate a tmux session before tab title.

Without -CC option, you should add -2 to force tmux support 256 colors.

Helpful tmux commands

iTerm2 and tmux Integration

Install and configure tmux on Mac OS X

Byobu

brew install byobu

fish

curl -L https://get.oh-my.fish | fish

oh-my-fish

omf install bobthefish

theme-bobthefish

omf install autojump
omf install brew
omf install cd
omf install code
omf install fasd
omf install fzf
omf install git-flow
omf install marlin
omf install osx
omf install proxy
omf install tab
omf install thefuck
omf install vcs
omf install z

plugin-brew plugin-cd plugin-vscode plugin-fasd plugin-git-flow marlin plugin-osx plugin-proxy plugin-tab plugin-thefuck plugin-vcs plugin-z

Set default

Append which fish to /etc/shells

sudo vi /etc/shells
chsh -s `which fish`

Awesome fish

Zsh

Zsh

color theme

export TERM=screen-256color in ~/.zshrc

set -g default-terminal "screen-256color" in ~/.tmux.conf

set t_Co=256 in ~/.vimrc

check

tput colors
echo $TERM

Download solarized

Install iterm2-colors-solarized/Solarized\ Dark.itermcolors and osx-terminal.app-colors-solarized/xterm-256color/Solarized\ Dark\ xterm-256color.terminal.

In iTerm: iTerm -> Prefs... -> Terminal -> Report Terminal Type: -> xterm-256color

In Terminal: Terminal -> Prefs... -> Settings -> Advanced -> Emulation -> Declare terminal as: -> xterm-256color

Then set as default in iTerm and Terminal.

(It seems doesn't work in Terminal. Needs manually steal every color from iTerm to Terminal?)

Solarized color scheme

Solarized colorscheme for vim

tmuxinator

gem install tmuxinator

Add to ~/.zshrc

plugins=(tmuxinator)

VSCode

Enable key repeats

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

How to enable key repeats on your Mac

Open the Command Palette (⇧⌘P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.

Running VS Code on Mac

Pass - as an argument to explicitly signal that the output of a piped command is coming in through stdin. For example:

ps aux | grep code | code -

The Fuck

brew install thefuck

Add to ~/.zshrc

plugins=(... thefuck)

autojump

brew install autojump

Add to ~/.zshrc

plugins=(... autojump)

Go to recent directories just write

j $DIRECTORY

And it will jump to the most frequently used directory with that name.

k

brew install k
git clone https://github.com/supercrabtree/k $HOME/.oh-my-zsh/custom/plugins/k

Add to ~/.zshrc

plugins=(k)

openssh

System Prefrences... -> Sharing -> Remote Login

gcc

Down Command Line Tools from Apple website and install it.

gdb

brew options gdb
brew install gdb --with-all-targets --with-python
brew info gdb
echo "set startup-with-shell off" >> ~/.gdbinit

Code Sign

If you try to use your freshly built gdb, you will get an error message such as:

Starting program: /x/y/foo
Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))

This is because the Darwin kernel will refuse to allow gdb to debug another process if you don't have special rights, since debugging a process means having full control over that process, and that isn't allowed by default since it would be exploitable by malware. (The kernel won't refuse if you are root, but of course you don't want to be root to debug.)

The most up to date method to allow gdb to control another process is to sign it with any system-trusted code signing authority. This is an easy process once you have a certificate (see the link below). If the certificate is known as gdb-cert, just use:

codesign -s gdb-cert `which gdb`

BuildingOnDarwin

gdbgui

gdbgui

CMake

brew options cmake
brew install cmake --with-completion

Go

brew install go

Add to ~/.zshrc

plugins=(go golang)

Mac OSX下Golang交叉编译

Rust

brew install rust  # --with-llvm

Add to ~/.zshrc

plugins=(rust cargo)
cargo install exa

Ruby

Don't use rbenv zsh plugin for a bug https://github.com/lewagon/setup/issues/40.

brew install ruby
rbenv which gem  # should be `/usr/local/lib/ruby/gems/2.5.0`
brew install rbenv ruby-build

Run rbenv init and follow the instructions to set up rbenv integration.

Close your Terminal window and open a new one so your changes take effect.

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash

Install Ruby

rbenv versions
rbenv install 2.5.1
rbenv rehash

Write 2.5.1 to ~/.ruby-version

rbenv which gem  # should be `/Users/xxx/.rbenv/versions/2.5.1/bin/gem`
gem env home  # should be `/Users/xxx/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0`
gem install bundler
gem install colorls

https://github.com/rbenv/rbenv#homebrew-on-macos

Add to ~/.zshrc

# colorls
source $(dirname $(gem which colorls))/tab_complete.sh

Docker

Docker

fzf

brew install fzf
/usr/local/opt/fzf/install

gnu

How to replace Mac OS X utilities with GNU core utilities? Install and Use GNU Command Line Tools on Mac OS X

brew install coreutils --with-gmp
brew install binutils
brew install diffutils
brew install findutils --with-default-names
brew install gawk
brew install gnu-indent --with-default-names
brew install gnu-sed --with-default-names
brew install gnutls --with-guile --with-unbound
brew install grep --with-default-names
brew install gnu-tar --with-default-names

The --default-names option is optional, turn on this if you really need to use these GNU commands as default ones, or they will be compiled with a g prefix.

dircolors-solarized

Add to ~/.zshrc

alias l='gls --color -ap'
alias ll='gls --color -lahsp'

# dircolors
eval `gdircolors ~/.dircolors/dircolors.ansi-dark`

dev tools

Tools list https://github.com/trimstray/the-book-of-secret-knowledge

https://ivarch.com/programs/pv.shtml

Pipe Viewer - is a terminal-based tool for monitoring the progress of data through a pipeline.

brew install clang-format  # <https://clang.llvm.org/docs/ClangFormatStyleOptions.html>
brew install sift
brew install ag
brew install ack
brew install pt
brew install cgrep
brew install editorconfig
brew install htop --with-ncurses
brew install hping  # <http://www.hping.org/>
brew install mosh
brew install hping
brew install ccat
brew install catimg
brew install tree
brew install hub
brew install grc
brew install spark
brew install z
brew install magic-wormhole
brew install pstree
brew install sysdig
brew install yarn
brew install tldr  # Simplified and community-driven man pages
brew install micro
brew install httpie  # [Modern command line HTTP client](https://github.com/jakubroztocil/httpie)
brew install lrzsz
brew install wget --with-gpgme --with-libmetalink --with-pcre

# <https://github.com/BurntSushi/ripgrep>
brew install ripgrep

# <https://github.com/BurntSushi/xsv>
# A fast CSV command line toolkit written in Rust
brew install xsv

# <https://github.com/tidwall/jj>
brew tap tidwall/jj
brew install jj  # JSON Stream Editor (command line utility)

# <https://github.com/rgcr/m-cli>
# Swiss Army Knife for macOS
brew install m-cli

pip3 install 'glances[action,browser,cloud,cpuinfo,chart,docker,export,folders,gpu,ip,raid,snmp,web,wifi]'  # An Eye on your system
pip3 install cheat
pip3 install crocs  # Regex for humans

Glances

# <https://github.com/sindresorhus/trash>
# Move files and directories to the trash
yarn glabal add trash-cli

yarn global add gtop  # System monitoring dashboard for terminal
yarn global add html-primer  # generates HTML5 boilerplates

Method 1 (Recommended)

Add to ~/.zshrc

plugins=(catimg mosh)

Method 2

. `brew --prefix`/etc/profile.d/z.sh

Apps

App Tamer

Reduce invisible apps' cpu usage.

Moom

Dock window to one side in Windows style.

SizeUp

Dock window to one side in Windows style.

Manico

Use Option + Number to switch app.

Peep

View and modify file encode.

Popcorn-Time

P2P movie.

NoSleep

Caffeine

Prevent your Mac from going to sleep and displaying the screen saver.

iTools Pro

Manage iPhone.

Tongbu Assistant

Manage iPhone.

iExplorer

Manage iPhone.

PhoneView

Manage iPhone.

Finder

System Prefs... -> Keyboard -> Keyboard -> -> Check Use all F1, F2, etc. keys

System Prefs... -> Keyboard -> Shortcuts -> Mission Control -> Select All controls

System Prefs... -> Keyboard -> Shortcuts -> Mission Control -> Uncheck all F1 ~ F12 shortcuts

XtraFinder

http://www.trankynam.com/xtrafinder/

Shortcat

https://shortcatapp.com/

Keyboard control

Bartender

Arrange status bar icon

midnight commander

brew install midnight-commander
mc

Fantastical

Calendar

Dash

AP reference

FUSE for macOS

https://github.com/osxfuse/osxfuse/releases

VeraCrypt

https://veracrypt.codeplex.com/

Tad

A desktop application for viewing and analyzing tabular data

https://github.com/antonycourtney/tad

Seil

https://pqrs.org/osx/karabiner/seil.html.en

Proxy

https://www.proxifier.com/mac_download.htm

SN: P427L-9Y552-5433E-8DSR3-58Z68

ClashX

Aria2

brew install aria2

https://github.com/alanzhangzm/Photon

Motrix

https://github.com/agalwood/Motrix

Youtube

docker run -d -p 3000:3000 algram/ytdl-webserver

ytdl-webserver

Preference Panes

RCDefaultApp

Set the default application used for various URL schemes, file extensions, file types, MIME types, and Uniform Type Identifiers.

Beautify

The Matrix

https://github.com/will8211/unimatrix

矮矬穷Mac桌面美化得瑟教程 Mac亲们!Mac的桌面也有神美化效果啊!GeekTool... 继Geek Tool后的第二弹后续萌化~~

Delete Caches

brew cleanup
rm -rf ~/Library/Caches/Homebrew/

迁移

复制 ~/Library/Application Support/iTerm2/Scripts/ 微信聊天记录、企业微信聊天记录、RTX聊天记录、iTerm配置、VS Code配置、Bartender配置、OneTab记录、Proxy SwitchyOmega配置、Tamper Monkey配置、Tab Modifier配置、The Great Suspender配置、Alfred配置、vim、spacemacs

https://github.com/zenorocha/alfred-workflows https://www.alfredapp.com/workflows/ https://github.com/isometry/alfred-tty

Recent Posts
  • Overview
  • System
  • XCode
  • homebrew
    • doctor
    • Path
    • cask
  • git
  • gperftools
  • fd
  • The Silver Searcher
  • Python
  • Emacs
  • Neovim
  • vim
  • iTerm
    • Color
    • Key
    • guake
    • Shell Integration
  • tmux
    • Byobu
  • fish
  • Zsh
  • color theme
  • tmuxinator
  • VSCode
  • The Fuck
  • autojump
  • k
  • openssh
  • gcc
  • gdb
  • Code Sign
  • gdbgui
  • CMake
  • Go
  • Rust
  • Ruby
  • Docker
  • fzf
  • gnu
  • dev tools
    • Method 1 (Recommended)
    • Method 2
  • Apps
    • App Tamer
    • Moom
    • SizeUp
    • Manico
    • Peep
    • Popcorn-Time
    • NoSleep
    • Caffeine
    • iTools Pro
    • Tongbu Assistant
    • iExplorer
    • PhoneView
    • Finder
    • XtraFinder
    • Shortcat
    • Bartender
    • midnight commander
    • Fantastical
    • Dash
    • FUSE for macOS
    • VeraCrypt
    • Tad
    • Seil
    • Proxy
    • Aria2
    • Motrix
    • Youtube
  • Preference Panes
  • Beautify
    • The Matrix
  • Delete Caches
  • 迁移
Tao He
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2019 Your Name or Your Company Name