ohmyzsh使用指南
本文介绍一下ohmyzsh的学习和使用过程:
参考资料6和7为主要配置流程:
参考资料:
- [GitHub - ohmyzsh/ohmyzsh: 🙃 A delightful community-driven (with 2,100+ contributors) framework for managing your zsh configuration)
- Installing ZSH · ohmyzsh/ohmyzsh Wiki · GitHub
- windows subsystem for linux - [process exited with code 1], can’t open WSL, zsh - Stack Overflow
- 优雅简洁的zim美化你的zsh终端,媲美甚至超越 ohmyzsh - 勒勒乐了 - 博客园
- 优雅简洁的zim美化你的zsh终端,媲美甚至超越 ohmyzsh_哔哩哔哩_bilibili
- 终端神器ohmyzsh_哔哩哔哩_bilibili
- Linux/Mac OS下安装并配置oh my zsh | SunPages:重点参考
- GitHub - unixorn/awesome-zsh-plugins: A collection of ZSH frameworks, plugins, themes and tutorials.
- oh-my-zsh让终端好用到飞起~ - 掘金
将.bashrc中的alias迁移到.zshrc
参考资料:
zsh在/mnt/…目录中的git仓库中prompt很慢
参考资料:
代理配置
配置完成后:
proxy set
:开启代理proxy unset
:关闭代理proxy test
:查看代理状态
参考资料:
为指定用户安装zsh (不需要root权限)
下述安装过程主要参考资料5和资料6:
- 从源码安装
zsh
的依赖包ncurses
:
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz tar xf ncurses-6.1.tar.gz
cd ncurses-6.1 ./configure --prefix=$HOME/local CXXFLAGS="-fPIC" CFLAGS="-fPIC"
make -j && make install
- 构建并安装
zsh
(将下述命令写入脚本zsh.sh
并运行sh zsh.sh
:
ZSH_SRC_NAME=$HOME/packages/zsh.tar.xz
ZSH_PACK_DIR=$HOME/packages/zsh
ZSH_LINK="https://sourceforge.net/projects/zsh/files/latest/download"
if [[ ! -d "$ZSH_PACK_DIR" ]]; then
echo "Creating zsh directory under packages directory"
mkdir -p "$ZSH_PACK_DIR"
fi
if [[ ! -f $ZSH_SRC_NAME ]]; then
curl -Lo "$ZSH_SRC_NAME" "$ZSH_LINK"
fi
tar xJvf "$ZSH_SRC_NAME" -C "$ZSH_PACK_DIR" --strip-components 1
cd "$ZSH_PACK_DIR"
./configure --prefix="$HOME/local" \
CPPFLAGS="-I$HOME/local/include" \
LDFLAGS="-L$HOME/local/lib"
make -j && make install
- 设置默认shell为
zsh
。创建~/.bash_profile
文件并写入:
export PATH=$HOME/local/bin:$PATH
export SHELL=`which zsh`
[ -f "$SHELL" ] && exec "$SHELL" -l
- 运行
source ~/.bash_profile
启动zsh
。选择q
选项暂不进行配置,此时位于zsh shell。 - 直接采用资料6中的配置(可以将
ohmyzsh.sh
下载到本地运行sh ohmyzsh.sh
sh -c "$(curl -fsSL https://www.sunhanwu.top/upload/2022/12/ohmyzsh.sh)"
- 安装第三方插件:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- 在
.zshrc
中配置所需要的插件(功能介绍见资料6):
bash plugins=( git extract fzf z zsh-autosuggestions zsh-syntax-highlighting wd sudo )
- 将原本
.bashrc
中的alias
和export
配置写入~/.bash_aliases
和~/.bash_path
文件。然后在.zshrc
文件中写入生效:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_path ]; then
. ~/.bash_path
fi
运行source ~/.zshrc
即可生效。
参考资料:
- zsh/INSTALL at master · zsh-users/zsh · GitHub
- software installation - Installing zsh from source file without root user access - Unix & Linux Stack Exchange
- Z-Shell Frequently-Asked Questions
- linux - Install zsh without root access? - Stack Overflow
- Building Zsh from Source and Configuring It on CentOS - jdhao’s digital space
- Linux/Mac OS下安装并配置oh my zsh | SunPages
git bash中安装zsh和ohmyzsh
参考资料:
安装autojump插件实现目录跳转
参考资料:
安装powerlevel10k主题
- 重置配置:
p10k configure
- 在git bash和MobaTermX中会出现某些配置直接被跳过的情况,其原因为这些终端不支持256colors,
参考资料:
VSCode Icons图标显示
方案一: 安装MesloLGS NF
字体并设置。
方案二:下载参考资料2中的扩展Fira Code
字体。
参考资料: