init
This commit is contained in:
commit
5c6d832cd6
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
plugins/
|
||||
bin/
|
67
README.md
Normal file
67
README.md
Normal file
@ -0,0 +1,67 @@
|
||||
# LAZYZSH ZSH 终端增强懒人包
|
||||
|
||||
## 特性
|
||||
|
||||
- 基本的 zsh 配置(高性能 prompt 美化 + 命令高亮 + 历史命令提示)
|
||||
- 常用的 alias 配置(详情查看 [alias.zsh](./alias.zsh))
|
||||
- WSL2 中有用的 alias 和环境变量
|
||||
- 好用的命令 cli 整合(可选项,仅支持 Linux 环境)
|
||||
|
||||
## 前提
|
||||
|
||||
1. zsh
|
||||
2. git
|
||||
|
||||
## 安装
|
||||
|
||||
lazyzsh 的目录为 `~/.lazyzsh/`
|
||||
**一行命令安装**
|
||||
|
||||
```
|
||||
git clone --depth 1 https://git.unvec.site/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`;
|
||||
- 你可以修改`x_add_cli.zsh`开头内容以禁止一些 cli 安装及其初始设定;
|
||||
- 目前所安装的程序仅支持 latest 最新版,重新执行命令即可全部 cli 更新。
|
||||
- 该过程确保`tar`和`curl`命令可用。
|
||||
**一行命令安装**
|
||||
|
||||
```
|
||||
zsh ~/.lazyzsh/x_add_cli.zsh
|
||||
```
|
||||
|
||||
> [!Note]
|
||||
> 此步骤需要访问 **Github** 资源,请确保网络可用。
|
||||
|
||||
目前整合的 cli 命令行程序有:
|
||||
|
||||
- 7zip
|
||||
- fastfetch
|
||||
- superfile
|
||||
- zoxide
|
||||
- bottom
|
||||
- fd
|
||||
- bat
|
||||
- aichat
|
||||
|
||||
## 其他
|
||||
|
||||
- wsl2 关闭 Win 防火墙拦截
|
||||
PowerShell 管理远模式打开 根据自己的 WSL 网卡类型执行
|
||||
|
||||
```powershell
|
||||
# 网卡 vEthernet (WSL (Hyper-V firewall))
|
||||
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))" -Action Allow
|
||||
|
||||
# 网卡 vEthernet (WSL)
|
||||
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
|
||||
```
|
13
alias.zsh
Normal file
13
alias.zsh
Normal 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
|
4
init_plugins.zsh
Normal file
4
init_plugins.zsh
Normal file
@ -0,0 +1,4 @@
|
||||
mkdir -p "$LAZY_ZSH/plugins"
|
||||
git clone --depth 1 "https://gitcode.com/zsh-users/zsh-syntax-highlighting.git" "$LAZY_ZSH/plugins/syntax-highlighting"
|
||||
git clone --depth 1 "https://gitcode.com/zsh-users/zsh-autosuggestions.git" "$LAZY_ZSH/plugins/autosuggestions"
|
||||
git clone --depth 1 "https://gitcode.com/romkatv/powerlevel10k.git" "$LAZY_ZSH/plugins/powerlevel10k"
|
53
lazy.zsh
Normal file
53
lazy.zsh
Normal file
@ -0,0 +1,53 @@
|
||||
#!/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" ]] && {
|
||||
if echo ":$PATH:" | grep -q ":lazyzsh:"; then
|
||||
source $LAZY_ZSH/bin/.lazy_bin_init.zsh
|
||||
else
|
||||
PATH="$LAZY_ZSH/bin:$PATH"
|
||||
source $LAZY_ZSH/bin/.lazy_bin_init.zsh
|
||||
fi
|
||||
}
|
||||
|
||||
# ~/.zsh_history
|
||||
setopt histignorealldups sharehistory
|
||||
HISTSIZE=1000
|
||||
SAVEHIST=1000
|
||||
HISTFILE="$HOME/.zsh_history"
|
||||
|
||||
# alias wsl2 profile
|
||||
source "$LAZY_ZSH/alias.zsh" # inner custom alias
|
||||
[[ -n $WSL_DISTRO_NAME ]] && source "$LAZY_ZSH/wsl2.zsh" # wsl custom
|
||||
[[ -f ~/.profile ]] && source ~/.profile # load bash profile
|
||||
|
||||
# Proxy Switcher
|
||||
function setproxy() {
|
||||
local host=${1:-127.0.0.1} # 更改IP为您的代理软件监听IP, 默认127.0.0.1
|
||||
local port=${2:-7897} # 更改端口为您的代理软件监听端口, 默认7897
|
||||
export http_proxy=http://$host:$port && export https_proxy=$http_proxy
|
||||
export no_proxy=localhost,127.0.0.1,::1,.localdomain
|
||||
echo "- You've set the network proxy! Info: $http_proxy"
|
||||
}
|
||||
function unsetproxy() {
|
||||
unset http_proxy && unset https_proxy && unset no_proxy
|
||||
echo "- You've unset the network proxy!"
|
||||
}
|
1719
p10k_theme.zsh
Normal file
1719
p10k_theme.zsh
Normal file
File diff suppressed because it is too large
Load Diff
10
wsl2.zsh
Normal file
10
wsl2.zsh
Normal file
@ -0,0 +1,10 @@
|
||||
# This zsh is for the wsl distro
|
||||
alias open="/mnt/c/Windows/explorer.exe"
|
||||
alias notepad="/mnt/c/Windows/notepad.exe"
|
||||
|
||||
export NET_GATE="$(/bin/ip r | head -n1 | cut -d' ' -f3)"
|
||||
|
||||
# WSLG
|
||||
export DISPLAY="$NET_GATE:0.0"
|
||||
export LIBGL_ALWAYS_INDIRECT=true
|
||||
export LIBGL_ALWAYS_SOFTWARE=true
|
120
x_add_cli.zsh
Normal file
120
x_add_cli.zsh
Normal file
@ -0,0 +1,120 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# 1改为0或者注释掉行 -> 禁用安装
|
||||
cli_7zip=1 # 7zip压缩 https://www.7-zip.org
|
||||
cli_fastfetch=1 # 系统信息 https://github.com/fastfetch-cli/fastfetch
|
||||
cli_superfile=1 # 文件管理 https://github.com/yorukot/superfile
|
||||
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
|
||||
cli_bat=1 # 内容查看 https://github.com/sharkdp/bat
|
||||
cli_aichat=1 # AI聊天 https://github.com/sigoden/aichat
|
||||
|
||||
## 安装
|
||||
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/7z2409-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_superfile == 1 ]] && {
|
||||
echo "[lazyzsh:x] add cli-superfile"
|
||||
curl $(gh_release yorukot/superfile "linux.*amd64\.tar\.gz") -Lo $LAZY_BIN_TMP/superfile.tar.gz
|
||||
if [[ $? == 0 ]]; then
|
||||
tar -zxf $LAZY_BIN_TMP/superfile.tar.gz -C $LAZY_BIN_TMP
|
||||
cp $(find $LAZY_BIN_TMP -name spf) $LAZY_BIN
|
||||
else
|
||||
echo "[lazyzsh:x] cli-superfile 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
|
||||
echo 'alias cd=z' >>$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
|
||||
}
|
||||
|
||||
[[ $cli_bat == 1 ]] && {
|
||||
echo "[lazyzsh:x] add cli-bat"
|
||||
curl $(gh_release sharkdp/bat x86_64-unknown-linux-gnu.tar.gz) -Lo $LAZY_BIN_TMP/bat.tar.gz
|
||||
if [[ $? == 0 ]]; then
|
||||
tar -zxf $LAZY_BIN_TMP/bat.tar.gz -C $LAZY_BIN_TMP
|
||||
cp $(find $LAZY_BIN_TMP -name bat) $LAZY_BIN
|
||||
else
|
||||
echo "[lazyzsh:x] cli-bat download fail!"
|
||||
fi
|
||||
}
|
||||
|
||||
[[ $cli_aichat == 1 ]] && {
|
||||
echo "[lazyzsh:x] add cli-aichat"
|
||||
curl $(gh_release sigoden/aichat x86_64-unknown-linux-musl.tar.gz) -Lo $LAZY_BIN_TMP/aichat
|
||||
if [[ $? == 0 ]]; then
|
||||
tar -zxf $LAZY_BIN_TMP/aichat -C $LAZY_BIN_TMP
|
||||
cp $LAZY_BIN_TMP/aichat $LAZY_BIN
|
||||
echo 'alias @=aichat' >>$LAZY_BIN_INIT
|
||||
else
|
||||
echo "[lazyzsh:x] cli-aichat download fail!"
|
||||
fi
|
||||
}
|
||||
|
||||
rm -r $LAZY_BIN_TMP
|
||||
|
||||
echo ""
|
||||
echo "🚀 LazyZSH cli group has been over!"
|
Loading…
x
Reference in New Issue
Block a user