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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

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!