Skip to content

Instantly share code, notes, and snippets.

@lesonky
Last active May 16, 2021 08:38
Show Gist options
  • Save lesonky/0e1a663b796c80a029bcd7ae4fc5fb2f to your computer and use it in GitHub Desktop.
Save lesonky/0e1a663b796c80a029bcd7ae4fc5fb2f to your computer and use it in GitHub Desktop.
Mac 配置
alias reload="source ~/.zshrc"
alias zshrc="code ~/.zshrc"
alias aliasrc="code ~/.setting/.alias"
alias del="rm -rf"
alias cls="clear"
alias useproxy="export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890"
alias unuseproxy="unset https_proxy http_proxy all_proxy"
alias gitproxy="git config --global https.proxy https://127.0.0.1:7890"
alias ungitproxy="git config --global --unset https.proxy"

# copy alias
alias pc='pbcopy'
alias pp='pbpaste'
alias pcurl='pp | xargs curl -s '
alias pget='pp | xargs wget'
alias pclone='pp | xargs git clone'
alias peval='pp | bash'
alias pdown='pp | xargs aria2c'

# yarn
alias y='yarn'
alias ya='yarn add'
alias yu='yarn upgrade'
alias yr='yarn remove'
alias yg='yarn global'
alias yga='yarn global add'
alias ygu='yarn global upgrade'
alias ygr='yarn global remove'
[https]
	proxy = https://127.0.0.1:1086
[user]
	name = shaojiasong
	email = lesonky@163.com
[alias]
    st = status
    ci = commit
    ciam = "commit -am"
    br = branch
    co = checkout 
    lg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
[sendemail]
    smtpuser = lesonky@163.com
    smtpserver = smtp.163.com
    smtpencryption = tls
    smtpserverport = 25
    suppresscc = self
[core]
    autocrlf = input
    editor = code --wait
[merge]
    tool = vscode
[mergetool "vscode"]
    cmd = code --wait $MERGED
    trustExitCode = false
    keepTemporaries = false
    keepBackup = false
    prompt = false
[diff]
    tool = vscode
[difftool "vscode"]
    cmd = code --wait --diff $LOCAL $REMOTE

示例

Host github.com
    Hostname github.com
    user git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/shaojiasong/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

# See https://gist.github.com/lesonky/3fa9120238cb85e0d41c27a371dd2aa4
ZSH_THEME="myagnoster"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  z 
  git 
  osx
  extract 
  autojump
  web-search 
  zsh-autosuggestions 
  zsh-syntax-highlighting 
)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# get local ip and copy(there is a problem )
# history time format

# for tmux
if [ -f /etc/profile ]; then
  PATH=""
  source /etc/profile
fi

# for pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1;
  then
    eval "$(pyenv init -)"
fi

export HIST_STAMPS="yyyy-mm-dd"

# flutter
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

# for autojump
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh

# ip functions
copyIp() {
    ifconfig  | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}' | pbcopy
}
showIp() {
    copyIp | pbpaste
}

# add alias
source ~/.setting/.alias

# nvmrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# place this after nvm initialization!
# call nvm use automatically whenever you enter a directory that contains an .nvmrc file 
autoload -U add-zsh-hook
load-nvmrc() {
  local node_version="$(nvm version)"
  local nvmrc_path="$(nvm_find_nvmrc)"

  if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
      nvm install
    elif [ "$nvmrc_node_version" != "$node_version" ]; then
      nvm use
    fi
  elif [ "$node_version" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default
  fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

开源软件列表

其他一些资源

oh-my-zsh 插件

  • zsh-syntax-highlighting git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  • web-search git clone https://github.com/lesonky/web-search.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/web-search
  • autojump
  • zsh-autosuggestions git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Tmux配置参考

alacritty 配置

  • 在home目录新建 .alacritty.yml 文件, 参考下面配置字体,其他配置可以看文档.
  • 最好配合 tmux 使用
font:
  size: 14
  normal:
    family: 'SauceCodePro Nerd Font'
    style: 'Light'

vim 升级

  • 去github 下载 vim 源码
  • 去源码目录 make & sudo make install
  • 编辑 zshrc 文件
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
  • 链接 vi 到 vim sudo ln -s /usr/local/bin/vim /usr/local/bin/vi
  • source ~/.zshrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment