哦我的天啊 Zsh + PowerLevel10k = 😎 终端

2025-05-24

哦我的天啊 Zsh + PowerLevel10k = 😎 终端

大家好,开发人员一直在使用终端,但它很枯燥,没有颜色和形状。
今天,我们将把我们的终端改造成一个精美、色彩丰富、支持性强、提供建议并具有记忆功能的终端。我们将由OMZ开发,并由PowerLevel10k设计……

先决条件

如果您使用的是Windows,则可以安装和配置WSL

我建议使用UbuntuDebian wsl 插件

设置zsh

在命令行中输入



# homebrew
brew install zsh

# apt-get
sudo apt-get install zsh


Enter fullscreen mode Exit fullscreen mode

输入zsh



zsh


Enter fullscreen mode Exit fullscreen mode

安装Oh My Zsh



sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"


Enter fullscreen mode Exit fullscreen mode

功率等级10k

  • 使用以下命令安装 Powerlevel10k


# gh cli
gh repo clone romkatv/powerlevel10k $ZSH_CUSTOM/themes/powerlevel10k

# git
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k


Enter fullscreen mode Exit fullscreen mode

然后您需要启用它,将文件中的 ZSH_THEME 值更改为以下内容~/.zshrc



ZSH_THEME="powerlevel10k/powerlevel10k"


Enter fullscreen mode Exit fullscreen mode

配置 Powerlevel10k 主题

  • 确保您的终端字体是FiraCode NF

字体链接:url

对于 Windows 用户:url

替代文本

Windows 版备忘单

如果您Windows terminal可以打开您的设置并在UNIX首选项中添加fontFaceprop,
然后将其分配给FiraCode NF



{
  "guid": "{YOUR_UNIX_GUID}",
  "hidden": false,
  "name": "Ubuntu",
  "source": "Windows.Terminal.Wsl",
  "fontFace": "FiraCode NF",
  "snapOnInput": true,
  "useAcrylic": true
}


Enter fullscreen mode Exit fullscreen mode

Microsoft Store 中的 Windows 终端 URL:url

Windows 终端 repo:url

p10k 配置

类型



p10k configure


Enter fullscreen mode Exit fullscreen mode

x

您可以选择您的风格...

插件(可选,最好有!)

克隆插件

  • zsh-syntax-highlighting - 它支持在交互式终端的 zsh 提示符下输入命令时高亮显示。这有助于在运行命令之前进行检查,尤其是在捕获语法错误方面。


# gh cli
gh repo clone zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting


Enter fullscreen mode Exit fullscreen mode
  • zsh-autosuggestions - 它根据历史记录和完成情况在您输入时建议命令。


# gh cli
gh repo clone zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# git
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions


Enter fullscreen mode Exit fullscreen mode

ls工具

  • colorlsls :一个使用颜色和图标为输出着色的 Ruby 脚本

  • exa :是ls的现代替代品

颜色



sudo gem install colorls


Enter fullscreen mode Exit fullscreen mode

警告🙃

你可能会遇到一些gem错误,你应该修复它

Linux



sudo apt install ruby-full


Enter fullscreen mode Exit fullscreen mode

埃克萨



brew install exa


Enter fullscreen mode Exit fullscreen mode

机密管理器

  • secman:人性化且令人惊叹的秘密管理器。


# via npm
npm install -g secman

# via script
curl -fsSL https://cli.secman.dev | bash


Enter fullscreen mode Exit fullscreen mode

文件传输应用程序

  • tran:使用 TUI 在计算机之间安全地传输和发送任何内容。


curl -sL https://cutt.ly/tran-cli | bash


Enter fullscreen mode Exit fullscreen mode

特别感谢

特别感谢

向我展示exa

激活插件

~/.zshrc文件中,将以 开头的行替换plugins=()为下面一行。



plugins=( git zsh-syntax-highlighting zsh-autosuggestions )


Enter fullscreen mode Exit fullscreen mode

颜色



if [ -x "$(command -v colorls)" ]; then
    alias ls="colorls"
    alias la="colorls -al"
fi


Enter fullscreen mode Exit fullscreen mode

或 exa



if [ -x "$(command -v exa)" ]; then
    alias ls="exa"
    alias la="exa --long --all --group"
fi


Enter fullscreen mode Exit fullscreen mode

更多官方插件 - ohmyzsh 插件

完成所有这些步骤后,请输入



source ~/.zshrc

Enter fullscreen mode Exit fullscreen mode




最后应该是这样的👇

苹果

替代文本

Windows(WSL)或 Linux

替代文本

替代文本

就这样吧,下次再见👋

文章来源:https://dev.to/abdfnx/oh-my-zsh-powerlevel10k-cool-terminal-1no0
PREV
你应该停止使用的 SQL 查询
NEXT
面向软件开发人员的 8 款顶级系统设计绘图工具📐✏️📏