powerline-go

一個美觀實用、低延遲的Shell提示工具,使用Go語言編寫。

powerline-go 是什麼?

一個美觀實用、低延遲的Shell提示工具,使用Go語言編寫。

powerline-go 概覽

這是什麼

powerline-go 是一個用 Go 語言撰寫的低延遲 shell 提示工具,支援 Bash、ZSH、Fish 與 PowerShell。它基於 @banga 的 Powerline-Shell,並由 @justjanne 移植到 Go。預設使用 ANSI 色彩碼,並需要安裝 powerline 字型(或使用相容/平面模式)才能顯示預設的修補後介面。此專案託管於 GitHub,採用 GPL-3.0 授權。

主要功能

  • 顯示 git/hg 分支詳細資訊,包括髒狀態、提交差異(推送/拉取指示符),以及已修改、暫存、衝突、未追蹤檔案與 stash 的符號。
  • 若上一個指令執行失敗(非零退出碼),提示顏色會改變。
  • 當目錄層級過深時,會以省略號縮短路徑顯示。
  • 顯示目前的 Python virtualenv 環境。
  • 顯示使用 rbenv 或 rvm 的 Ruby 版本。
  • 顯示是否處於 nix shell 環境中。
  • 支援透過命令列旗標自訂(例如 -cwd-mode、-git-mode、-colorize-hostname、-duration)。

使用情境

  • 開發者想要一個視覺化且資訊豐富的 shell 提示,能一目了然顯示版本控制狀態、錯誤碼與環境資訊。
  • 使用者同時使用多種 shell(Bash、ZSH、Fish、PowerShell),希望提示風格一致。
  • 需要低延遲提示,且能處理大型 git 儲存庫(可透過選項停用特定 git 狀態以提升效能)。
  • 在 nix-shell 環境中需要保留提示顯示的使用者。

快速開始

使用 Go 安裝(需要 Go 1.15+): bash go install github.com/justjanne/powerline-go@latest Bash 使用者請在 .bashrc 中加入: bash function _update_ps1() { PS1='$($GOPATH/bin/powerline-go -error $? -jobs $(jobs -p | wc -l))' } if [ '$TERM' != 'linux' ] && [ -f '$GOPATH/bin/powerline-go' ]; then PROMPT_COMMAND='_update_ps1; $PROMPT_COMMAND' fi ZSH 使用者請在 .zshrc 中加入: bash function powerline_precmd() { PS1='$($GOPATH/bin/powerline-go -error $? -jobs ${${(%):%j}:-0})' } function install_powerline_precmd() { for s in '${precmd_functions[@]}'; do if [ '$s' = 'powerline_precmd' ]; then return fi done precmd_functions+=(powerline_precmd) } if [ '$TERM' != 'linux' ] && [ -f '$GOPATH/bin/powerline-go' ]; then install_powerline_precmd fi Fish 使用者請在 ~/.config/fish/config.fish 中加入: bash function fish_prompt eval $GOPATH/bin/powerline-go -error $status -jobs (count (jobs -p)) end PowerShell 使用者請在設定檔中重新定義 prompt 函式(完整範例請見儲存庫 README)。

授權與價格

此專案採用 GPL-3.0 授權。為開放原始碼且免費使用。除授權條款外,未提及任何價格資訊。

內容整理自該專案公開的 README 與儲存庫資訊。

將此徽章加入你的 README

Featured on YunoDB 徽章樣式與說明

你是這個專案的維護者嗎?展示它已收錄於 YunoDB。

Markdown[![Featured on YunoDB](https://yunodb.com/badge/justjannepowerline-go.svg)](https://yunodb.com/tools/justjannepowerline-go?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/justjannepowerline-go?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/justjannepowerline-go.svg" alt="Featured on YunoDB" height="20"></a>