[Mac] WorkFlow
This is a collection of configurations that includes all on my Mac.
Clash
Enhance terminal
# 终端下执行以下几个命令,然后重新登出当前账户并登入(或者重启)
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Set a blazingly fast keyboard repeat rate
# 默认值 2,设置成 1 合适,设置成 0 就太快了
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
Git Config
-
refer to new SSH key
git config --global user.email "xxx@foxmail.com"
git config --global user.name "xxx"
# ssh-key
brew install openssh
ssh-keygen -t ed25519 -C "your_email@example.com"
touch ~/.ssh/config
# add to ~/.ssh/config
Host github.com
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519
ssh-add ~/.ssh/id_ed25519
pbcopy < ~/.ssh/id_ed25519.pub
# then add to your github settings->ssh key
# set proxy
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
#unset
git config --global --unset http.proxy
git config --global --unset https.proxy
# pretty git log
# add to ~/.zshrc
alias glog='git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit -n 20' -
gitignore global
echo .DS_Store >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
Homebrew
Use pkg to install homebrew, but need to config ~/.zshrc
# add blew to ~/.zshrc
eval "$(/opt/homebrew/bin/brew shellenv)"
# set ustc mirrors
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
# export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
# then
source ~/.zshrc
brew update
# if unistall then
brew autoremove
brew cleanup
Font
perfer nerd fonts nerd fonts
# https://github.com/ryanoasis/nerd-fonts#option-8-patch-your-own-font
# Usage
cd FontPatcher
# then
fontforge -script font-patcher PATH_TO_FONT
# e.g: fontforge -script font-patcher ~/Documents/Fonts/RecMonoCasual/RecMonoCasual-Italic-1.085.ttf --complete
# then u can find xxxNerdFont.ttf in current path
starship
-
install starship
# brew install starship
vim ~/.zshrc
# add
eval "$(starship init zsh)"
# config
# use prsent & restart terminal
starship preset nerd-font-symbols -o ~/.config/starship.toml -
Zsh plugins
# zsh-autosuggestions
brew install zsh-autosuggestions
# zsh-syntax-highlighting
brew install zsh-syntax-highlighting
# autojump
brew install autojump
# add to ~/.zshrc
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh
# by default zsh is case sensitive
# Ignore Case Sensitive
autoload -Uz +X compinit && compinit
zstyle ':completion:' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:' menu select
# then source ~/.zshrc -
last directory
# add to ~/.zshrc
chpwd() {
# Save the current directory to a file
echo $PWD > ~/.last_directory
}
[ -f ~/.last_directory ] && cd $(cat ~/.last_directory)
Iterm2
config refer to iterm2 dotfiles
Tmux
config refer to tmux dotfiles
Neovim
config refer to nvim dotfiles
vimrc
config vim
vim ~/.vimrc
" basic
syntax on
set t_Co=256
" set termguicolors
set background=dark
set nocompatible
set number
set nowrap
set mouse=a
set clipboard=unnamed
" tab
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
set autoindent
set backspace=eol,start,indent
" search
set showmatch
set hlsearch
set incsearch
set ignorecase
set smartcase
set regexpengine=0
" menu
set showcmd
set showmode
set wildmenu
" other
set nobackup
set nowb
set nowritebackup
set noswapfile
set noerrorbells
" encoding
" set spell spelllang=en_us
set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
filetype indent on
" auto tag
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap < <><ESC>i
inoremap ' ''<ESC>i
inoremap " ""<ESC>i
let g:indentLine_enabled = 1
" move to beginning/end of line
nnoremap H ^
nnoremap L $
" $/^ doesn't do anything
nnoremap $ <nop>
nnoremap ^ <nop>
Golang
Setup
# brew install
brew install go
go version
brew upgrade go
# pkg install
https://go.dev/dl/
# set env
mkdir -p $HOME/Documents/Code/Project_Go/pkg
mkdir -p $HOME/Documents/Code/Project_Go/bin
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=on
go env -w GOPATH=$HOME/Documents/Code/Path_Go
# gofumpt
go install mvdan.cc/gofumpt@latest
Books
- Go 语言圣经 https://golang-china.github.io/gopl-zh/index.html
- Go 语言设计与实现 https://draveness.me/golang/
- Go 语言高级编程 https://chai2010.cn/advanced-go-programming-book/index.html
Rust
Setup
Refer to set up
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
其他命令:
rustc --version
cargo --version
rustup update
-
官方文档中文 https://rustwiki.org/
-
Rust 程序设计语言 https://rustwiki.org/zh-CN/book/
-
Rust 程序设计语言 https://doc.rust-lang.org/book/ch01-01-installation.html
-
Rust Cookbook 中文版 https://rustwiki.org/zh-CN/rust-cookbook/
Awesome Rust
-
awesome rust https://github.com/rust-unofficial/awesome-rust
-
Rust 嵌入式 https://github.com/rust-embedded/awesome-embedded-rust
VsCode
config refer to vscode dotfiles
CLI Tools
refer to Modern Unix
bat
cat clone with syntax highlighting and Git integration
brew install bat
# config
bat --generate-config-file
# add to ~/.config/bat/config
--paging=never
--theme="gruvbox-dark"
--style="numbers,changes,header,snip,rule"
# add to ~/.zshrc
alias cat='bat'