Skip to content

Latest commit

 

History

History
525 lines (388 loc) · 11.9 KB

README.md

File metadata and controls

525 lines (388 loc) · 11.9 KB

[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
defaults write NSGlobalDomain KeyRepeat -int 1  # 默认值 2,设置成 1 合适,设置成 0 就太快了
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
    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

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)

kitty

config refer to kitty dotfiles

Yazi

config refer to yazi dotfiles

also add config to ~/.zshrc

# yazi
function ya() {
	local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
	yazi "$@" --cwd-file="$tmp"
	if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
		builtin cd -- "$cwd"
	fi
	rm -f -- "$tmp"
}

Iterm2

config refer to iterm2 dotfiles

iterm2

Tmux

config refer to tmux dotfiles

tmux

Neovim

config refer to nvim dotfiles

dashboard

telescope

outline

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

Rust

Setup

Refer to set up

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

其他命令:

rustc --version
cargo --version
rustup update

Awesome 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'
# Install
brew install git-delta
# config
# add this to ~/.gitconfig
[core]
    pager = delta
[interactive]
    diffFilter = delta --color-only
[delta]
    syntax-theme = gruvbox-dark
    # this config auto set line-numbers=true
    side-by-side = true
[merge]
    conflictstyle = diff3
# Using Delta with tmux add to tmux.conf
# set -ga terminal-overrides ",xterm-256color:Tc"-
  • fd - a simple, fast and user-friendly alternative to 'find'
brew install fd
  • fzf - command-line fuzzy finder
# add to ~/.zshrc

# fzf config
eval "$(fzf --zsh)"
# use ~~ as the trigger sequence instead of the default **
export FZF_COMPLETION_TRIGGER='~~'
export FZF_DEFAULT_OPTS='--height 50% --layout=reverse'
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"

show_file_or_dir_preview="if [ -d {} ]; then tree -C {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"

_fzf_compgen_path() {
  fd --hidden --exclude .git . "$1"
}
_fzf_compgen_dir() {
  fd --type=d --hidden --exclude .git . "$1"
}
_fzf_comprun() {
  local command=$1
  shift

  case "$command" in
    cd)           fzf --preview 'tree -C {} | head -200'   "$@" ;;
    ssh)          fzf --preview 'dig {}'                   "$@" ;;
    *)            fzf --preview 'bat -n --color=always {}' "$@" ;;
  esac
}

# source
source ~/.zshrc
  • fzf-git - completion selection menu with fzf
cd ~/.zsh
git clone git@github.com:junegunn/fzf-git.sh.git
# add to ~/.zshrc
source ~/.zsh/fzf-git.sh/fzf-git.sh
brew install ripgrep
  • bottom - process/system monitor
brew install bottom
# use
btm
  • lsd - ls command
brew install lsd

# add to ~/.zshrc
alias ls='lsd'
alias la='ls -la'
alias lt='ls --tree'
mkdir -p $HOME/Documents/Tools/Cheat/bin
curl https://cht.sh/:cht.sh > "$HOME/Documents/Tools/Cheat/bin/cht.sh"
chmod +x "$HOME/Documents/Tools/Cheat/bin/cht.sh"

# config ~/.zshrc
# cheat.sh
export CHEAT_DIR=$HOME/Documents/Tools/Cheat
export PATH=$PATH:$CHEAT_DIR/bin
source ~/.zshrc

#use like
cht.sh go chan
# prefer use
cht.sh --shell [LANG]
  • httpie - command-line HTTP client
# use  https://httpie.io/docs/cli/redirected-input

Apps

  • AlDente -- charge limiter app

  • lemon -- mac clean app

  • iTerm2 -- Terminal app

  • Sequel Ace -- mysql management

  • Vimium -- Chrome & Arc extension for Vim

    # config Custom key
    unmap /
    map <c-/> enterFindMode
    # Custom search engines
    # so u can press o and enter g/bd/gh to search something
    bd: http://www.baidu.com/s?wd=%s+-csdn Baidu
    g: https://www.google.com/search?q=%s Google
    gh: https://github.com/search?q=%s GitHub
  • sublime text -- buy license from taobao

    {
     "ignored_packages":
     [
      "Vintage",
     ],
     "color_scheme": "ayu-light.sublime-color-scheme",
     "theme": "ayu-light.sublime-theme",
     "always_prompt_for_file_reload": true,
     "font_size": 16,
     "remember_open_files": true,
     "update_check": false,
     "font_face": "RecMonoCasual Nerd Font",
    }
  • PicGo -- upload images to GitHub

    if u forget your GitHub tokens, u cant find it in the blew file data.json

    // the data.json saved all the uploaded imgs info
    // this is vscode settings
    "picgo.dataPath": "$home/Library/Application Support/picgo/data.json",

    If use typora & picgo app, when u pasted images in typora,it will cached images in the path$home/Library/Application\ Support/typora-user-images,so u need clean it.