reconstruct dir

This commit is contained in:
2026-01-21 22:50:39 +08:00
parent 429f8fc2d6
commit c5be794640
7 changed files with 263 additions and 193 deletions

109
zsh/zshrc
View File

@@ -1,76 +1,55 @@
# 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"
#!/bin/zsh
# 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 # 保存历史时忽略重复项
# path -> settings -> alias -> functions -> plugins -> prompt
# Load Aliases
source $ZSH_ALIAS_PATH/alias.sh
if [ -n "${ZSH_VERSION}" ]; then
_source="${(%):-%x}"
_path=$(dirname "$(realpath "$_source")")
unset _source
else
echo "Unsupported shell"
exit 1
fi
# Set basic path to zsh-polyjuice installation
export ZSH_POLYJUICE_PATH="$_path"
unset _path
export ZSH_PLUGINS_PATH="$ZSH_POLYJUICE_PATH/plugins"
export ZSH_ALIAS_PATH="$ZSH_POLYJUICE_PATH/alias"
export ZSH_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings"
export ZSH_FUNCTIONS_PATH="$ZSH_POLYJUICE_PATH/functions"
export STARSHIP_CONFIG_FILE="$ZSH_POLYJUICE_PATH/../starship/starship.toml"
# Load basic settings `zsh/settings`
for _file in "$ZSH_SETTINGS_PATH"/*.sh; do
source "$_file"
done
unset _file
# Load Aliases `zsh/alias`
for _file in "$ZSH_ALIAS_PATH"/*.sh; do
source "$_file"
done
unset _file
# Load self-defined functions
for _file in "$ZSH_FUNCTIONS_PATH"/*.sh; do
source "$_file"
done
unset _file
# Load Plugins
source $ZSH_PLUGIN_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh
source $ZSH_PLUGINS_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_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh
source $ZSH_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $ZSH_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh
source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/fzf/fzf.plugin.zsh
source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/zoxide/zoxide.plugin.zsh
source $ZSH_PLUGINS_PATH/ohmyzsh/plugins/python/python.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)