shell-config/.zshrc

122 lines
4.4 KiB
Bash

# 设置history文件路径
export HISTFILE=~/.zsh_history
# 设置保存的history条目数量
export HISTSIZE=1000
export SAVEHIST=1000
# 配置history选项
setopt appendhistory
setopt sharehistory
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zdharma-continuum/zinit-annex-as-monitor \
zdharma-continuum/zinit-annex-bin-gem-node \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-rust
### End of Zinit's installer chunk
zinit ice depth=1; zinit light romkatv/powerlevel10k
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-syntax-highlighting
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Command not found conf
source /etc/zsh_command_not_found
# eza config
########
if [[ $(command -v exa) ]] {
DISABLE_LS_COLORS=true
unset LS_BIN_FILE
for i (/bin/ls ${PREFIX}/bin/ls /usr/bin/ls /usr/local/bin/ls) {
[[ ! -x ${i} ]] || {
local LS_BIN_FILE=${i}
break
}
}
[[ -n ${LS_BIN_FILE} ]] || local LS_BIN_FILE=$(whereis ls 2>/dev/null | awk '{print $2}')
alias lls=${LS_BIN_FILE}
# lls is the original ls. lls为原版ls
alias ls="exa --color=auto"
# Exa is a modern version of ls. exa是一款优秀的ls替代品,拥有更好的文件展示体验,输出结果更快,使用rust编写。
alias l='exa -lbah --icons'
alias la='exa -labgh --icons'
alias ll='exa -lbg --icons'
alias lsa='exa -lbagR --icons'
alias lst='exa -lTabgh --icons' # 输入lst,将展示类似于tree的树状列表。
} else {
alias ls='ls --color=auto'
# color should not be always.
alias lst='tree -pCsh'
alias l='ls -lah'
alias la='ls -lAh'
alias ll='ls -lh'
alias lsa='ls -lah'
}
alias md=mkdir
if [[ $(command -v batcat) ]] {
alias bat=batcat
alias cat='bat -pp'
alias ccat=cat
}
# Key bindings for Ctrl+Arrow keys
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
# Ctrl+Backspace / Ctrl+Delete: 删除一个词(尝试常见序列)
# 说明:若终端发出的序列不同,按 Ctrl+V 然后按键查看实际输出,按需替换右侧的序列。
bindkey '^H' backward-kill-word # 有的终端 Ctrl+Backspace 输出 ^H
bindkey '^?' backward-kill-word # 有的终端输出 DEL (127)
bindkey '\e[1;5~' backward-kill-word # 常见的 Ctrl+Backspace 变体(部分终端)
bindkey '\e[7;5~' backward-kill-word
bindkey '\e[8;5~' backward-kill-word
bindkey '\e[3;5~' kill-word
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/lichx/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/lichx/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/lichx/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/lichx/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
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
alias set_proxy='export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890'
alias unset_proxy='unset http_proxy https_proxy'