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

推荐订阅源

酷 壳 – 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 idiot wrote this code? What's new #2 What's new #1
What's new #3
Jan De Dobbeleer · 2022-05-19 · via Oh My Posh Blog

So long, old friend!

PowerShell module

In the beginning, all we had was the PowerShell Module. It's the origin of Oh My Posh and has remained available ever since, even with the move to Go. With that evolution however, its advantages have been greatly reduced. In fact, it even introduced additional hurdles along the way.

As of March, the module no longer offers new functionality and displays a warning message. Have a look at the migration page for a guide on how to migrate from the module to other means of installation. It only takes a minute.

Giveaway

A fews weeks ago I started a giveaway to celebrate the 6 year anniversary of Oh My Posh. But then I went on holiday, and didn't follow up to announce the winner. So without further ado, congratulations to @samerde for getting picked by a random online random picker and winning the giveaway!

Features

It's been a while, so you might want to hang tight 😅

PowerShell UTF-8

In the early days, Oh My Posh was forcibly setting PowerShell to UTF-8 due to issues with fonts and paths. However, it turned out that wasn't really necessary. A new way of invocation was introduced, which removes the need to set this shell wide and avoids unwanted side effects. This can however still break path when for example your --config path contains a non-ascii character. Can't win them all I guess. In that case, set the shell to UTF-8 in the scope of initializing Oh My Posh.

$previousOutputEncoding = [Console]::OutputEncoding

[Console]::OutputEncoding = [Text.Encoding]::UTF8

try {

oh-my-posh init pwsh --config ~/custom.omp.json | Invoke-Expression

} finally {

[Console]::OutputEncoding = $previousOutputEncoding

}

Nu shell

If you haven't seen Nu shell yet, it's a new kid on the block. Oh My Posh now supports it just like we support any other popular shell (bash, zsh, fish, etc). This means we can keep adding functionality without the need for user interaction apart from updating Oh My Posh.

Accordion

Ever wanted to have a powerline segment to display collapsed when disabled? Now you can! Use the accordion style to display a segment in a collapsible state.

Accordion prompt

Project

Things just keep growing. The project segment now supports the following project definitions:

Shell

If you work with multiple shell versions, this one's for you. You can now use the .Version property in the shell segment to distinct between versions:

"template": " in {{ .Name }} {{ .Version }} "

Git

The git segment learned a new trick to make your life easier (or faster). Before we hardcoded the untracked files mode to normal. However, on larger repo's this can get rather cumbersome, so we now allow you to override this per repo.

"untracked_modes": {

"/Users/user/Projects/oh-my-posh/": "no"

}

The available options are listed in the git documentation, use them as you see fit!

Cross segment template properties

Wait, what? Yes, you read that right. Oh My Posh now supports cross segment template properties. This means you can use one segment's properties in another segment's template. How? Oh My Posh exposes the .Segments property which contains all segment's properties in a map. To make use of another segment's data, use {{ .Segments.Segment }} in your template where .Segment is the name of the segment you want to use with the first letter uppercased.

If you want to for example use the git segment's .UpstreamGone property in the exit segment, you can do so like this:

"template": " {{ if .Segments.Git.UpstreamGone }}\uf7d3{{ else if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} "

caution

For this to work, the segment you refer to needs to be in your config. The above example won't work if your config does not contain a git segment as Oh My Posh only populates the properties when it needs to.

Other

  • oh-my-posh debug now measures the run time correctly and can log startup logic
  • The language segments can now distinct between files and folders
  • The python segment now supports pyenv .python-version files
  • The init command has a new switch called --strict which no longer resolves the executable
  • The battery segment can now display all relevant states on macOS
  • The dotnet segment now supports .slnf files
  • A new segment to display iTerm shell integration prompt marks
  • The memory segment can now display available memory
  • The path segment now has a .Writable property, indicating if the current user can write to the current folder

Fixes

  • The git segment can now handle repo's with --separate-git-dir
  • Hyperlinks are correctly measured (which should display the right aligned prompt correctly)
  • Prompt escape sequences are correctly escaped, this avoids unwanted visual side effects
  • Spotify now works correctly on Windows for non-English systems
  • Parallel logic to make things fast no longer randomly crashes on Windows
  • Upstream gone logic for git was broken, and has been fixed
  • PSReadLine in PowerShell now receives the correct amount of prompt lines (Set-PSReadlineOption -ExtraPromptLineCount), this fixes weird behaviour when using a transient prompt when your config results in a multiline prompt
  • The winget installer now adds PATH entries correctly, regardless of the installation mode

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

Keep that prompt posh everyone!