Files
TerminalPolyjuice/zsh/zshrc

85 lines
3.1 KiB
Bash

# Path to zsh-polyjuice installation
export ZSH_POLYJUICE_PATH="$HOME/.TerminalPolyjuice"
export ZSH_PLUGIN_PATH="$ZSH_POLYJUICE_PATH/zsh/plugins"
export ZSH_ALIAS_PATH="$ZSH_POLYJUICE_PATH/zsh/alias"
# Command History related settings
HISTFILE=$HOME/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt append_history # 退出时追加到历史文件
setopt inc_append_history # 命令执行后立即写入历史文件
setopt share_history # 在多个终端间共享历史
setopt hist_ignore_dups # 忽略重复的命令
setopt hist_reduce_blanks # 合并连续的空命令
# setopt hist_verify # 通过 fc 编辑历史命令后再执行
# setopt extended_history # 记录时间戳
# setopt hist_expire_dups_first # 先删除重复的命令再根据大小删除
# setopt hist_find_no_dups # 搜索历史时忽略重复项
# setopt hist_save_no_dups # 保存历史时忽略重复项
# Load Aliases
source $ZSH_ALIAS_PATH/alias.sh
# Load Plugins
source $ZSH_PLUGIN_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
bindkey '^[l' autosuggest-accept # alt-L to accept autosuggestion
source $ZSH_PLUGIN_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh
source $ZSH_PLUGIN_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $ZSH_PLUGIN_PATH/fzf-tab/fzf-tab.plugin.zsh
source $ZSH_PLUGIN_PATH/ohmyzsh/plugins/fzf/fzf.plugin.zsh
source $ZSH_PLUGIN_PATH/ohmyzsh/plugins/python/python.plugin.zsh
# zoxide
if (( $+commands[zoxide] )); then
eval "$(zoxide init --cmd ${ZOXIDE_CMD_OVERRIDE:-z} zsh)"
else
echo '[zoxide] not found, please install it from https://github.com/ajeetdsouza/zoxide'
fi
# You may need to manually set your language environment
export LANG=en_US.UTF-8
export LC_ALL=C.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='nvim'
# fi
# Homebrew Tsinghua mirror for macOS
function brewthu() {
if [[ $HOMEBREW_BOTTLE_DOMAIN = "" ]]; then
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
# Bottles
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
else
unset HOMEBREW_API_DOMAIN
unset HOMEBREW_BOTTLE_DOMAIN
unset HOMEBREW_BREW_GIT_REMOTE
unset HOMEBREW_CORE_GIT_REMOTE
unset HOMEBREW_PIP_INDEX_URL
# Bottles
unset HOMEBREW_BOTTLE_DOMAIN
fi
}
function cdi() {
cd $(find . -type d | fzf)
}
# using starship as prompt
if (( $+commands[starship] )); then
eval "$(starship init zsh)"
else
echo '[starship] not found, please install it.'
fi