惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
小众软件
小众软件
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
S
Secure Thoughts
O
OpenAI News
P
Proofpoint News Feed
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
Tenable Blog
A
Arctic Wolf
L
LINUX DO - 热门话题
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
博客园_首页
雷峰网
雷峰网
IT之家
IT之家
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
H
Heimdal Security Blog

Oh My Posh Blog

Oh My Posh Meets Claude Code: AI-Powered Terminal Prompts Deprecating the bash rprompt What's new #3 What idiot wrote this code? What's new #1
What's new #2
Jan De Dobbeleer · 2022-03-27 · via Oh My Posh Blog

Wouldn't have imagined doing part two in a week's time, but here we are again!

Features

CLI interface (also #2)

In the previous post I highlighted some changes in the CLI interface. Turns out I could make it even more straightforward. As Oh My Posh is a prompt generating utility, the prompt command doesn't make sense as that's implied. It has been removed, although it will keep working to not break existing functionality on upgrade.

Init

The following initialization:

oh-my-posh prompt init pwsh | Invoke-Expression

now becomes:

oh-my-posh init pwsh | Invoke-Expression

Debug

To debug Oh My Posh, you can simply use the debug command. It's smart enough to know your config so you don't have to specify the --config option.

Fish shell

We already supported fish shell for a while, but we stepped up the game. I started using fish as my primary shell, so obviously it couldn't stay behind. I suggest you also have a go at it, it's a very enjoyable experience.

But OK, what changed? We now support the following out-of-the-box:

It seems there's no support (yet) for a secondary prompt in fish, once that's available we can easily add that too. To enjoy all of this, upgrade to the latest and initialize fish by adding the following line to ~/.config/fish/config.fish:

oh-my-posh init fish | source

Transient prompt

Speaking of transient, it learned some new tricks. First, you can now use the .Code property to work with the last command's error code (if any) in the template. This can for example be used to color the transient prompt differently when the last command failed. That did imply we also needed support for color templates, as that wasn't possible just yet. Say no more, we now have a transient prompt that supports color templates.

"transient_prompt": {

"background": "p:yellow",

"background_templates": [

"{{ if gt .Code 0 }}p:red{{ end }}"

],

"foreground": "p:black",

"foreground_templates": [

"{{ if gt .Code 0 }}p:white{{ end }}"

],

"template": "<background,transparent>\ue0b6</> {{ .Folder }} <background,transparent>\ue0b0</><,transparent> </>"

}

Which produces the following result:

Terminal

Config version 2

Remember we did a migration to config version 1 in the beginning of the year? Well, we did a migration to version 2. Looking at Oh My Posh's architecture, the different prompts (transient, secondary, ...) were moving closer to the model used by segments. The only difference was that template wasn't a property, but a field of those prompts. As all segments now have template support, it was a no-brainer to align both models and do a migration to config version 2 so nobody would have any manual work in the process.

The following segment definition:

{

"background": "#9A348E",

"foreground": "#ffffff",

"leading_diamond": "\ue0b6",

"properties": {

"template": "{{ .UserName }} "

},

"style": "diamond",

"type": "session"

}

Will now be migrated to this for version 2:

{

"background": "#9A348E",

"foreground": "#ffffff",

"leading_diamond": "\ue0b6",

"style": "diamond",

"template": "{{ .UserName }} ",

"type": "session"

}

Go 1.18

Not something that impacts the end user directly, but maybe interesting to know is that Oh My Posh is now using go 1.18 by default. This brings obvious language improvements and a few new features we can play with. The most notable is generics, but it doesn't seem like we can benefit just yet as it's not yet supported for methods, and that's the main use-case for us.

Nonetheless, it's good to stay up-to-date, if you notice any quirks though, be sure to let us know!

That's it for this week, see you for the next one 🤞🏻

Keep that prompt posh everyone!