This commit is contained in:
Steven Hobs
2026-03-04 11:27:19 +08:00
commit 2c0a1fdcb9
8 changed files with 1956 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
plugins/
bin/

58
README.md Normal file
View File

@@ -0,0 +1,58 @@
# LAZYZSH ZSH 终端增强懒人包
## 特性
- 基本的 zsh 配置(高性能 prompt 美化 + 命令高亮 + 历史命令提示)
- 常用的 alias 配置(详情查看 [alias.zsh](./alias.zsh)
- WSL2 中有用的 alias 和环境变量
- 好用的命令 cli 整合(可选项,仅支持 Linux 环境)
## 前提
1. zsh
2. git
## 安装
lazyzsh 的目录为 `~/.lazyzsh/`
**安装命令**
```
#克隆代码
git clone --depth 1 "https://github.com/stevenhobs/lazyzsh ~/.lazyzsh"
#镜像站克隆代码(如果克隆失败)
git clone --depth 1 "https://ghfast.top/https://github.com/stevenhobs/lazyzsh" ~/.lazyzsh
#引入配置
echo "source ~/.lazyzsh/lazy.zsh" >> ~/.zshrc
```
你可以修改`init_plugins.zsh`开头内容以禁用某些插件。
> [!Note]
> 更改登录的 shell 执行 `chsh --shell /bin/zsh`
### 引入第三方 cli 程序(可选)
- 安装的 cli 程序会存放在 `~/.lazyzsh/bin/`
- 安装的 cli 程序的初始化 zsh 文件 `~/.lazyzsh/bin/.lazy_bin_init.zsh`
- 你可以修改`install_cli.zsh`开头内容以禁止一些 cli 安装及其初始设定;
- 目前所安装的程序仅支持 latest 最新版,重新执行命令即可全部 cli 更新。
- 该过程会检测 `curl``grep``cut``tar``xz``cp``find``rm``mkdir` 命令是否可用。
**一行命令安装**
```
zsh ~/.lazyzsh/install_cli.zsh
```
> [!Note]
> 此步骤需要访问 **Github** 资源,请确保网络可用。
目前整合的 cli 命令行程序有:
- 7zip
- fastfetch
- zoxide
- bottom
- fd

13
alias.zsh Normal file
View File

@@ -0,0 +1,13 @@
alias s=sudo
alias ls="ls --color"
alias l="ls -CF"
alias ll="ls -alhF"
alias la="ls -A"
alias dir="dir --color"
alias grep="grep --color"
alias diff="diff --color"
alias egrep="egrep --color"
alias fgrep="fgrep --color"
alias md="mkdir -p"
alias ip="ip -c"
alias tou=touch

5
init_plugins.zsh Normal file
View File

@@ -0,0 +1,5 @@
mkdir -p "$LAZY_ZSH/plugins"
GITHUB_MIRROR="https://ghfast.top/"
git clone --depth 1 "${GITHUB_MIRROR}https://github.com/zsh-users/zsh-syntax-highlighting.git" "$LAZY_ZSH/plugins/syntax-highlighting"
git clone --depth 1 "${GITHUB_MIRROR}https://github.com/zsh-users/zsh-autosuggestions.git" "$LAZY_ZSH/plugins/autosuggestions"
git clone --depth 1 "${GITHUB_MIRROR}https://github.com/romkatv/powerlevel10k.git" "$LAZY_ZSH/plugins/powerlevel10k"

100
install_cli.zsh Normal file
View File

@@ -0,0 +1,100 @@
#!/bin/zsh
# 当前脚本不支持 macOS
if [[ "$(uname -s)" == "Darwin" ]]; then
echo "[lazyzsh:x] install_cli.zsh does not support macOS."
exit 1
fi
# 检测脚本依赖命令是否存在
required_cmds=(curl grep cut tar xz cp find rm mkdir)
missing_cmds=()
for cmd in "${required_cmds[@]}"; do
command -v "$cmd" >/dev/null 2>&1 || missing_cmds+=("$cmd")
done
if [[ ${#missing_cmds[@]} -gt 0 ]]; then
echo "[lazyzsh:x] missing required command(s): ${missing_cmds[*]}"
exit 1
fi
# 1改为0或者注释掉行 -> 禁用安装
cli_7zip=1 # 7zip压缩 https://www.7-zip.org
cli_fastfetch=1 # 系统信息 https://github.com/fastfetch-cli/fastfetch
cli_zoxide=1 # 智能cd https://github.com/ajeetdsouza/zoxide
cli_bottom=1 # 系统监测 https://github.com/ClementTsang/bottom
cli_fd=1 # 文件查找 https://github.com/sharkdp/fd
## 安装
LAZY_BIN=~/.lazyzsh/bin
LAZY_BIN_TMP=$LAZY_BIN/.tmp
LAZY_BIN_INIT=$LAZY_BIN/.lazy_bin_init.zsh
rm -rf $LAZY_BIN*
mkdir -p $LAZY_BIN_TMP
function gh_release() {
gh_link=$(curl -s https://api.github.com/repos/$1/releases/latest | grep browser_download_url | cut -d'"' -f4 | grep -E $2)
echo $gh_link
}
[[ $cli_7zip == 1 ]] && {
echo "[lazyzsh:x] add cli-7zip"
local CLI_7Z_DL_URL=https://www.7-zip.org/a/7z2600-linux-x64.tar.xz
curl $CLI_7Z_DL_URL -o $LAZY_BIN_TMP/7z.tar.xz
if [[ $? == 0 ]]; then
tar -xf $LAZY_BIN_TMP/7z.tar.xz -C $LAZY_BIN_TMP
cp $LAZY_BIN_TMP/7zz $LAZY_BIN
echo 'alias 7z=7zz' >>$LAZY_BIN_INIT
else
echo "[lazyzsh:x] cli-7zip download fail!"
fi
}
[[ $cli_fastfetch == 1 ]] && {
echo "[lazyzsh:x] add cli-fastfetch"
curl $(gh_release fastfetch-cli/fastfetch "fastfetch-linux-amd64.tar.gz") -Lo $LAZY_BIN_TMP/fastfetch.tar.gz
if [[ $? == 0 ]]; then
tar -zxf $LAZY_BIN_TMP/fastfetch.tar.gz -C $LAZY_BIN_TMP
cp $LAZY_BIN_TMP/fastfetch-linux-amd64/usr/bin/fastfetch $LAZY_BIN
else
echo "[lazyzsh:x] cli-fastfetch download fail!"
fi
}
[[ $cli_zoxide == 1 ]] && {
echo "[lazyzsh:x] add cli-zoxide"
curl $(gh_release ajeetdsouza/zoxide "x86_64-unknown-linux-musl.tar.gz$") -Lo $LAZY_BIN_TMP/zoxide.tar.gz
if [[ $? == 0 ]]; then
tar -zxf $LAZY_BIN_TMP/zoxide.tar.gz -C $LAZY_BIN_TMP
cp $LAZY_BIN_TMP/zoxide $LAZY_BIN
echo 'eval "$(zoxide init zsh)"' >>$LAZY_BIN_INIT
else
echo "[lazyzsh:x] cli-zoxide download fail!"
fi
}
[[ $cli_bottom == 1 ]] && {
echo "[lazyzsh:x] add cli-bottom"
curl $(gh_release ClementTsang/bottom bottom_x86_64-unknown-linux-gnu.tar.gz) -Lo $LAZY_BIN_TMP/bottom.tar.gz
if [[ $? == 0 ]]; then
tar -zxf $LAZY_BIN_TMP/bottom.tar.gz -C $LAZY_BIN_TMP
cp $LAZY_BIN_TMP/btm $LAZY_BIN
else
echo "[lazyzsh:x] cli-bottom download fail!"
fi
}
[[ $cli_fd == 1 ]] && {
echo "[lazyzsh:x] add cli-fd"
curl $(gh_release sharkdp/fd x86_64-unknown-linux-gnu.tar.gz) -Lo $LAZY_BIN_TMP/fd.tar.gz
if [[ $? == 0 ]]; then
tar -zxf $LAZY_BIN_TMP/fd.tar.gz -C $LAZY_BIN_TMP
cp $(find $LAZY_BIN_TMP -name fd) $LAZY_BIN
else
echo "[lazyzsh:x] cli-fd download fail!"
fi
}
rm -r $LAZY_BIN_TMP
echo ""
echo "🚀 LazyZSH cli group has been over!"

47
lazy.zsh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/zsh
[[ -o interactive ]] || return
# Options
ZSH_PLUGIN_syntax_highlighting=ON
ZSH_PLUGIN_autosuggestions=ON
ZSH_PLUGIN_powerlevel10k=ON
# LazyZSH Config
LAZY_ZSH="$HOME/.lazyzsh"
# Plugins
[[ ! -d "$LAZY_ZSH/plugins" ]] && . "$LAZY_ZSH/init_plugins.zsh"
[ "$ZSH_PLUGIN_syntax_highlighting" = ON ] && source "$LAZY_ZSH/plugins/syntax-highlighting/zsh-syntax-highlighting.zsh"
[ "$ZSH_PLUGIN_autosuggestions" = ON ] && source "$LAZY_ZSH/plugins/autosuggestions/zsh-autosuggestions.zsh"
[ "$ZSH_PLUGIN_powerlevel10k" = ON ] && {
source "$LAZY_ZSH/plugins/powerlevel10k/powerlevel10k.zsh-theme"
source "$LAZY_ZSH/p10k_theme.zsh"
}
# Binaries
[[ -d "$LAZY_ZSH/bin" ]] && ! echo ":$PATH:" | grep -q "lazyzsh/bin" && {
PATH="$LAZY_ZSH/bin:$PATH"
source $LAZY_ZSH/bin/.lazy_bin_init.zsh
}
# ~/.zsh_history
setopt histignorealldups sharehistory
HISTSIZE=1000
SAVEHIST=1000
HISTFILE="$HOME/.zsh_history"
source "$LAZY_ZSH/alias.zsh" # inner custom alias
[[ -n $WSL_DISTRO_NAME ]] && source "$LAZY_ZSH/wsl2.zsh" # wsl custom
# Proxy Switcher
function setproxy() {
local host=${1:-127.0.0.1} # 更改IP为您的代理软件监听IP, 默认127.0.0.1
local port=${2:-7890} # 更改端口为您的代理软件监听端口, 默认7890
export http_proxy=http://$host:$port && export https_proxy=$http_proxy
export no_proxy=localhost,127.0.0.1,::1,.localdomain
echo "- Set the network proxy! Info: $http_proxy"
}
function unsetproxy() {
unset http_proxy && unset https_proxy && unset no_proxy
echo "- UnSet the network proxy!"
}

1719
p10k_theme.zsh Normal file

File diff suppressed because it is too large Load Diff

12
wsl2.zsh Normal file
View File

@@ -0,0 +1,12 @@
# This zsh is for the wsl distro
alias open="/mnt/c/Windows/explorer.exe"
alias notepad="/mnt/c/Windows/notepad.exe"
export NET_GATE="$(ip -c=never r | head -n1 | cut -d' ' -f3)"
# WSLG
if [[ -z $DISPLAY ]]; then
export DISPLAY="$NET_GATE:0.0"
export LIBGL_ALWAYS_INDIRECT=true
export LIBGL_ALWAYS_SOFTWARE=true
fi