当前位置: 首页 > news >正文

在 Ubuntu 下配置 oh-my-posh —— 普通用户 + root 各自使用独立主题(共享可执行)

🧩 在 Ubuntu 下配置 oh-my-posh —— 普通用户 + root 各自使用独立主题(共享可执行)


✅ 目标说明

  • 普通用户 使用 tokyonight_storm 主题
  • root 用户 使用 1_shell 主题
  • 共用全局路径下的 oh-my-posh 可执行文件
  • 正确加载 Homebrew 到环境变量中
  • 分别加载独立的 .omp.json 配置 ✅

🔧 安装流程


🧱 1. 安装 Homebrew(普通用户下)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

🛠️ 2. 将 Brew 加入环境变量(写入 .bashrc

echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
source ~/.bashrc

📌 如果你使用 zsh,请改为 .zshrc


🧠 3. Nerd Font 字体设置(终端图标支持)

Ubuntu 本地终端
mkdir -p ~/.local/share/fonts/NerdFonts
cd ~/.local/share/fonts/NerdFontswget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip
unzip FiraCode.zip
rm FiraCode.zipfc-cache -fv
WSL2 设置方法
  • 打开 Windows Terminal → 选择配置的 profile

  • Appearance(外观) → Font → 设置为 FiraCode Nerd Font


📦 4. 安装 oh-my-posh

brew install jandedobbeleer/oh-my-posh/oh-my-posh

如遇编译错误提示:

sudo apt install clang

🪛 5. 将 oh-my-posh 拷贝至全局路径

sudo cp $(which oh-my-posh) /usr/local/bin/
sudo chmod +x /usr/local/bin/oh-my-posh

🎨 6. 下载全部主题文件(需先装 unzip)

sudo apt install unzip -ymkdir -p ~/.poshthemes
cd ~/.poshthemescurl -fLo themes.zip https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip
unzip themes.zip
chmod 644 *.omp.json
rm themes.zip

👤 普通用户配置(使用 tokyonight_storm)

🪛 编辑 ~/.bashrc

nano ~/.bashrc

加入:

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
eval "$(oh-my-posh init bash --config ~/.poshthemes/tokyonight_storm.omp.json)"

保存并生效:

source ~/.bashrc

👑 root 用户配置(使用 1_shell)

📁 拷贝主题文件到 root

sudo mkdir -p /root/.poshthemes
sudo cp ~/.poshthemes/1_shell.omp.json /root/.poshthemes/
sudo chmod 644 /root/.poshthemes/1_shell.omp.json

🪛 编辑 /root/.bashrc

sudo nano /root/.bashrc

添加:

eval "$(oh-my-posh init bash --config /root/.poshthemes/1_shell.omp.json)"

保存并生效:

sudo su
source ~/.bashrc

✅ 总结配置表

组件内容路径或值
Brew环境变量加载/home/linuxbrew/.linuxbrew/bin/brew shellenv
oh-my-posh全局可执行文件/usr/local/bin/oh-my-posh
普通用户使用 tokyonight_storm 主题~/.poshthemes/tokyonight_storm.omp.json
root 用户使用 1_shell 主题/root/.poshthemes/1_shell.omp.json

🎉 你现在已经完成了 oh-my-posh 的完整配置 🎨

http://www.lryc.cn/news/580425.html

相关文章:

  • 常见高危端口风险分析与防护指南
  • java中,stream的filter和list的removeIf筛选速度比较
  • 【网络协议安全】任务12:二层物理和单臂路由及三层vlanif配置方法
  • Docker文件操作、数据卷、挂载
  • 猎板 PCB 微孔技术:构建 5G 通信设备高效运行的坚实底座
  • 冒泡和快速排序的区别
  • 【Note】《深入理解Linux内核》 第十八章:深入理解 ext2 与 ext3 文件系统
  • 人工智能-基础篇-18-什么是RAG(检索增强生成:知识库+向量化技术+大语言模型LLM整合的技术框架)
  • 2025使用VM虚拟机安装配置Macos苹果系统下Flutter开发环境保姆级教程--中篇
  • 【算法笔记】4.LeetCode-Hot100-数组专项
  • 多任务学习-ESMM
  • 隐马尔可夫模型(HMM):观测背后的状态解码艺术
  • STM32HAL库总结
  • HuggingFists: 无代码处理复杂PDF
  • Debian、Buildroot 和 Ubuntu 都是基于 Linux 的系统区别
  • 在VMware虚拟机中安装Windows 98时,Explorer提示“该程序执行了非法操作,即将关闭”的解决办法
  • 若 VSCode 添加到文件夹内右键菜单中显示(通过reg文件方式)
  • linux系统源代码安装apache、编译隐藏版本号
  • ubuntu手动编译VTK9.3 Generating qmltypes file 失败
  • Cursor/VScode ,点击运行按钮,就打开新的终端,如何设置为在当前终端运行文件而不是重新打开终端----一招搞定篇
  • 高频交易服务器篇
  • Redis服务器
  • 【Elasticsearch】检索高亮
  • 【网络与爬虫 13】智能伪装:Scrapy-Fake-UserAgent反检测技术实战指南
  • Matplotlib 安装部署与版本兼容问题解决方案(pyCharm)
  • Vue.js TDD开发深度指南:工具链配置与精细化测试策略
  • Linux(centos)安装 MySQL 8
  • ADAS功能介绍
  • alpine安装及配置nodejs开发测试环境
  • 流水线(Jenkins)打包拉取依赖的时候提示无法拉取,需要登录私仓的解决办法