oh-my-posh installation tutorial

Introduction

There are detailed installation and usage instructions in the docs. If you don’t understand the following, you can move to the official documentation to learn and use it by yourself~

Install

The following is an example of the newly installed debian environment of x86_64

Linux debian 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux

Install for intranet and non-root users to avoid polluting the environment of other users

#!/bin/bash

# 获取posh可执行文件,内网环境可以直接从github中下载后,拷贝到用户下指定目录
# 当前命令中下载的可执行文件是基于amd64架构的,根据自己的系统架构选择下载
mkdir -p ~/oh-my-posh
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O ~/oh-my-posh/posh;
chmod +x ~/oh-my-posh/posh;

# 下载主题
mkdir -p ~/oh-my-posh/.poshthemes;
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/oh-my-posh/.poshthemes/themes.zip;
unzip -q ~/oh-my-posh/.poshthemes/themes.zip -d ~/oh-my-posh/.poshthemes;
rm ~/oh-my-posh/.poshthemes/themes.zip -vf;
chmod u+rw ~/oh-my-posh/.poshthemes/*.omp.*;

# 向~/.profile,或者~/.bashrc,或者~/.bash_profile中写入posh初始化命令,下面命令中以~/.profile为例,并指定主题 montys.omp.json
sed -i '$a eval "$(~/oh-my-posh/posh init bash --config ~/oh-my-posh/.poshthemes/montys.omp.json)"' ~/.profile;

# 重新启用bash
source ~/.profile;

# 若安装了zsh,则最后两行命令用下面两行替代
# 向~/.zshrc中写入posh初始化命令,并指定主题 montys.omp.json
#sed -i '$a eval "$(~/oh-my-posh/posh init zsh --config ~/oh-my-posh/.poshthemes/montys.omp.json)"' ~/.zshrc;
# 应用新的.zshrc文件
#exec zsh;

sample animation

montys.omp.json theme fine-tuning

Since the montys theme will output the complete path in the powerline by default, when the path level is deep, the powerline display is too long, so the reference document has been fine-tuned.

diff --git a/themes/montys.omp.json b/themes/montys.omp.json
index c7797e88..c8eeb6c4 100644
--- a/themes/montys.omp.json
+++ b/themes/montys.omp.json
@@ -17,10 +17,11 @@
           "foreground": "#ffffff",
           "powerline_symbol": "\ue0b0",
           "properties": {
-            "folder_icon": "\uf115",
+            "folder_icon": "\uf07c",
             "folder_separator_icon": "\\",
             "home_icon": "\uf7db",
-            "style": "full"
+            "style": "agnoster_short",
+            "max_depth": 3
           },
           "style": "powerline",
           "template": " <#000>\uf07b \uf553</> {
   
   { .Path }} ",

Effect comparison:

before:

after:

Guess you like

Origin blog.csdn.net/qq_38894585/article/details/128647777