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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint 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!