{"id":13487249,"url":"https://github.com/justjanne/powerline-go","last_synced_at":"2025-05-13T17:12:54.857Z","repository":{"id":41095063,"uuid":"100974617","full_name":"justjanne/powerline-go","owner":"justjanne","description":" A beautiful and useful low-latency prompt for your shell, written in go","archived":false,"fork":false,"pushed_at":"2025-04-19T09:21:24.000Z","size":770,"stargazers_count":2783,"open_issues_count":72,"forks_count":274,"subscribers_count":39,"default_branch":"main","last_synced_at":"2025-04-19T15:30:42.739Z","etag":null,"topics":["bash","color-scheme","developer-tools","fish","go","powerline","shell","theme","zsh"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justjanne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"justjanne","patreon":"justjanne"}},"created_at":"2017-08-21T17:02:24.000Z","updated_at":"2025-04-19T15:04:12.000Z","dependencies_parsed_at":"2023-12-26T03:09:09.395Z","dependency_job_id":"d5ca65fb-93ec-4e54-880d-d5040db458ff","html_url":"https://github.com/justjanne/powerline-go","commit_stats":{"total_commits":291,"total_committers":99,"mean_commits":"2.9393939393939394","dds":0.6460481099656357,"last_synced_commit":"059f7f230760f8800307b3ae632c6cc6ca3f81d4"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjanne%2Fpowerline-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjanne%2Fpowerline-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjanne%2Fpowerline-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justjanne%2Fpowerline-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justjanne","download_url":"https://codeload.github.com/justjanne/powerline-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250530301,"owners_count":21445760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","color-scheme","developer-tools","fish","go","powerline","shell","theme","zsh"],"created_at":"2024-07-31T18:00:57.040Z","updated_at":"2025-04-23T23:24:29.032Z","avatar_url":"https://github.com/justjanne.png","language":"Go","funding_links":["https://github.com/sponsors/justjanne","https://patreon.com/justjanne"],"categories":["Alternative Engines","Themes","Go","Repositories"],"sub_categories":["ZSH on Windows","Zinit (née zplugin)"],"readme":"# A Powerline style prompt for your shell\n\nA [Powerline](https://github.com/Lokaltog/vim-powerline) like prompt for Bash,\nZSH and Fish. Based on [Powerline-Shell](https://github.com/banga/powerline-shell) by @banga.\nPorted to golang by @justjanne.\n\n![Solarized+Powerline](https://raw.github.com/justjanne/powerline-go/main/preview.png)\n\n- Shows some important details about the git/hg branch (see below)\n- Changes color if the last command exited with a failure code\n- If you're too deep into a directory tree, shortens the displayed path with an ellipsis\n- Shows the current Python [virtualenv](http://www.virtualenv.org/) environment\n- Shows the current Ruby version using [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io/)\n- Shows if you are in a [nix](https://nixos.org/) shell\n- It's easy to customize and extend. See below for details.\n\n**Table of Contents**\n\n- [Version Control](#version-control)\n- [Installation](#installation)\n  - [Precompiled Binaries](#precompiled-binaries)\n  - [Other Platforms](#other-platforms)\n  - [Bash](#bash)\n  - [ZSH](#zsh)\n  - [Fish](#fish)\n  - [Nix](#nix)\n  - [PowerShell](#powershell)\n- [Customization](#customization)\n- [License](#license)\n\n## Version Control\n\nAll of the version control systems supported by powerline shell give you a\nquick look into the state of your repo:\n\n- The current branch is displayed and changes background color when the\n  branch is dirty.\n- When the local branch differs from the remote, the difference in number\n  of commits is shown along with `⇡` or `⇣` indicating whether a git push\n  or pull is pending\n\nIn addition, git has a few extra symbols:\n\n- `✎` -- a file has been modified, but not staged for commit\n- `✔` -- a file is staged for commit\n- `✼` -- a file has conflicts\n- `+` -- untracked files are present\n- `⚑` -- stash is present\n\nEach of these will have a number next to it if more than one file matches.\n\n## Installation\n\nRequires Go 1.15+\n\n`powerline-go` uses ANSI color codes, these should nowadays work everywhere,\nbut you may have to set your $TERM to `xterm-256color` for it to work.\n\nIf you want to use the \"patched\" mode (which is the default, and provides\nimproved UI), you'll need to install a powerline font, either as fallback,\nor by patching the font you use for your terminal: see\n[powerline-fonts](https://github.com/Lokaltog/powerline-fonts).\nAlternatively you can use \"compatible\" or \"flat\" mode.\n\n### Precompiled Binaries\n\nI provide precompiled binaries for x64 Linux and macOS in the\n[releases tab](https://github.com/justjanne/powerline-go/releases)\n\n### Other Platforms\n\n- Install (and update) the package with\n\n```bash\ngo install github.com/justjanne/powerline-go@latest\n```\n\n- By default it will be in `$GOPATH/bin`, if you want to change that, you can set\n  your `$GOPATH` and/or `$GOBIN`, but will need to change the path in the\n  following scripts, too.\n\n### Bash\n\nAdd the following to your `.bashrc`:\n\n```bash\nfunction _update_ps1() {\n    PS1=\"$($GOPATH/bin/powerline-go -error $? -jobs $(jobs -p | wc -l))\"\n\n    # Uncomment the following line to automatically clear errors after showing\n    # them once. This not only clears the error for powerline-go, but also for\n    # everything else you run in that shell. Don't enable this if you're not\n    # sure this is what you want.\n\n    #set \"?\"\n}\n\nif [ \"$TERM\" != \"linux\" ] \u0026\u0026 [ -f \"$GOPATH/bin/powerline-go\" ]; then\n    PROMPT_COMMAND=\"_update_ps1; $PROMPT_COMMAND\"\nfi\n```\n\nCurrently, right prompt support is not available when using bash.\n\n### ZSH\n\nAdd the following to your `.zshrc`:\n\n```bash\nfunction powerline_precmd() {\n    PS1=\"$($GOPATH/bin/powerline-go -error $? -jobs ${${(%):%j}:-0})\"\n\n    # Uncomment the following line to automatically clear errors after showing\n    # them once. This not only clears the error for powerline-go, but also for\n    # everything else you run in that shell. Don't enable this if you're not\n    # sure this is what you want.\n\n    #set \"?\"\n}\n\nfunction install_powerline_precmd() {\n  for s in \"${precmd_functions[@]}\"; do\n    if [ \"$s\" = \"powerline_precmd\" ]; then\n      return\n    fi\n  done\n  precmd_functions+=(powerline_precmd)\n}\n\nif [ \"$TERM\" != \"linux\" ] \u0026\u0026 [ -f \"$GOPATH/bin/powerline-go\" ]; then\n    install_powerline_precmd\nfi\n```\n\n### Fish\n\nRedefine `fish_prompt` in `~/.config/fish/config.fish`:\n\n```bash\nfunction fish_prompt\n    eval $GOPATH/bin/powerline-go -error $status -jobs (count (jobs -p))\nend\n```\n### Nix\n\nWhen using `nix-shell --pure`, `powerline-go` will not be accessible, and\nyour prompt will disappear.\n\nTo work around this you can add this snippet to your `.bashrc`,\nwhich should re-enable the prompt in most cases:\n\n```bash\n# Workaround for nix-shell --pure\nif [ \"$IN_NIX_SHELL\" == \"pure\" ]; then\n    if [ -x \"$HOME/.nix-profile/bin/powerline-go\" ]; then\n        alias powerline-go=\"$HOME/.nix-profile/bin/powerline-go\"\n    elif [ -x \"/run/current-system/sw/bin/powerline-go\" ]; then\n        alias powerline-go=\"/run/current-system/sw/bin/powerline-go\"\n    fi\nfi\n```\n\n### Powershell\n\nRedefine `prompt` function on your profile:\n\n```powershell\n# Load powerline-go prompt\nfunction global:prompt {\n    $pwd = $ExecutionContext.SessionState.Path.CurrentLocation\n    $startInfo = New-Object System.Diagnostics.ProcessStartInfo\n    $startInfo.FileName = \"powerline-go\"\n    $startInfo.Arguments = \"-shell bare\"\n    $startInfo.Environment[\"TERM\"] = \"xterm-256color\"\n    $startInfo.CreateNoWindow = $true\n    $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8\n    $startInfo.RedirectStandardOutput = $true\n    $startInfo.UseShellExecute = $false\n    $startInfo.WorkingDirectory = $pwd\n    $process = New-Object System.Diagnostics.Process\n    $process.StartInfo = $startInfo\n    $process.Start() | Out-Null\n    $standardOut = $process.StandardOutput.ReadToEnd()\n    $process.WaitForExit()\n    $standardOut\n}\n```\n\nUse `ProcessStartInfo` is needed to allow fill the enviromnet variables required by powerline-go.\n\n## Customization\n\nThere are a few optional arguments which can be seen by running\n`powerline-go -help`. These can be used by changing the command you have set\nin your shell’s init file.\n\n```\nUsage of powerline-go:\n  -alternate-ssh-icon\n         Show the older, original icon for SSH connections\n  -colorize-hostname\n         Colorize the hostname based on a hash of itself, or use the PLGO_HOSTNAMEFG and PLGO_HOSTNAMEBG env vars (both need to be set).\n  -fqdn-hostname\n         Use the longer fully qualified domain name as the hostname\n  -condensed\n         Remove spacing between segments\n  -cwd-max-depth int\n         Maximum number of directories to show in path\n         (default 5)\n  -cwd-max-dir-size int\n         Maximum number of letters displayed for each directory in the path\n         (default -1)\n  -cwd-mode string\n         How to display the current directory\n         (valid choices: fancy, semifancy, plain, dironly)\n         (default \"fancy\")\n  -duration string\n         The elapsed clock-time of the previous command\n  -duration-min string\n         The minimal time a command has to take before the duration segment is shown (default \"0\")\n  -east-asian-width\n         Use East Asian Ambiguous Widths\n  -error int\n         Exit code of previously executed command\n  -eval\n         Output prompt in 'eval' format.\n  -git-assume-unchanged-size int\n         Disable checking for changed/edited files in git repositories where the index is larger than this size (in KB), improves performance (default 2048)\n  -git-disable-stats string\n         Comma-separated list to disable individual git statuses\n         (valid choices: ahead, behind, staged, notStaged, untracked, conflicted, stashed)\n  -git-mode string\n         How to display git status\n         (valid choices: fancy, compact, simple)\n         (default \"fancy\")\n  -hostname-only-if-ssh\n         Show hostname only for SSH connections\n  -ignore-repos string\n         A list of git repos to ignore. Separate with ','.\n         Repos are identified by their root directory.\n  -ignore-warnings\n         Ignores all warnings regarding unset or broken variables\n  -jobs int\n         Number of jobs currently running\n  -max-width int\n         Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem.\n  -mode string\n         The characters used to make separators between segments.\n         (valid choices: patched, compatible, flat)\n         (default \"patched\")\n  -modules string\n         The list of modules to load, separated by ','\n         (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)\n         Unrecognized modules will be invoked as 'powerline-go-MODULE' executable plugins and should output a (possibly empty) list of JSON objects that unmarshal to powerline-go's Segment structs.\n         (default \"venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root\")\n  -modules-right string\n         The list of modules to load anchored to the right, for shells that support it, separated by ','\n         (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, wsl)\n         Unrecognized modules will be invoked as 'powerline-go-MODULE' executable plugins and should output a (possibly empty) list of JSON objects that unmarshal to powerline-go's Segment structs.\n  -newline\n         Show the prompt on a new line\n  -numeric-exit-codes\n         Shows numeric exit codes for errors.\n  -path-aliases string\n         One or more aliases from a path to a short name. Separate with ','.\n         An alias maps a path like foo/bar/baz to a short name like FBB.\n         Specify these as key/value pairs like foo/bar/baz=FBB.\n         Use '~' for your home dir. You may need to escape this character to avoid shell substitution.\n  -priority string\n         Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','\n         (valid choices: aws, bzr, cwd, direnv, docker, docker-context, dotenv, duration, exit, fossil, gcp, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, rbenv, root, rvm, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo, vi-mode, wsl)\n         (default \"root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path\")\n  -shell string\n         Set this to your shell type\n         (valid choices: autodetect, bare, bash, zsh)\n         (default \"autodetect\")\n  -shell-var string\n         A shell variable to add to the segments.\n  -shell-var-no-warn-empty\n         Disables warning for empty shell variable.\n  -shorten-eks-names\n         Shortens names for EKS Kube clusters.\n  -shorten-gke-names\n         Shortens names for GKE Kube clusters.\n  -static-prompt-indicator\n         Always show the prompt indicator with the default color, never with the error color\n  -theme string\n         Set this to the theme you want to use\n         (valid choices: default, low-contrast, gruvbox, solarized-dark16, solarized-light16)\n         (default \"default\")\n  -trim-ad-domain\n         Trim the Domainname from the AD username.\n  -truncate-segment-width int\n         Maximum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it.\n         (default 16)\n  -venv-name-size-limit int\n         Show indicator instead of virtualenv name if name is longer than this limit (defaults to 0, which is unlimited)\n  -vi-mode string\n         The current vi-mode (eg. KEYMAP for zsh) for vi-module module\n```\n\n### Eval\n\nIf using `eval` and `-modules-right` is desired, the shell setup must be modified slightly, as shown below:\n\n##### Bash\n\nAdd the following to your `.bashrc`:\n\n```bash\nfunction _update_ps1() {\n    eval \"$($GOPATH/bin/powerline-go -error $? -shell bash -eval -modules-right git)\"\n}\n\nif [ \"$TERM\" != \"linux\" ] \u0026\u0026 [ -f \"$GOPATH/bin/powerline-go\" ]; then\n    PROMPT_COMMAND=\"_update_ps1; $PROMPT_COMMAND\"\nfi\n```\n\n##### ZSH\n\nAdd the following to your `.zshrc`:\n\n```bash\nfunction powerline_precmd() {\n    eval \"$($GOPATH/bin/powerline-go -error $? -shell zsh -eval -modules-right git)\"\n}\n\nfunction install_powerline_precmd() {\n  for s in \"${precmd_functions[@]}\"; do\n    if [ \"$s\" = \"powerline_precmd\" ]; then\n      return\n    fi\n  done\n  precmd_functions+=(powerline_precmd)\n}\n\nif [ \"$TERM\" != \"linux\" ]; then\n    install_powerline_precmd\nfi\n```\n\n##### Fish\n\nEval mode (and `modules-right` support) for Fish is not currently available.\n\n### Path Aliases\n\nThe point of the path aliases feature is to allow you to replace long paths\nwith a shorter string that you can understand more quickly. This is useful if\nyou're often in deep path hierarchies that end up consuming most of your\nterminal width, even when some portions are replaced by an ellipsis.\n\nFor example, you might want to replace the string `$GOPATH/src/github.com` with\n`@GOPATH-GH`. When you're in a directory like\n`$GOPATH/src/github.com/justjanne/powerline-go`, you'll instead see `@GOPATH-GH \u003e\njustjanne \u003e powerline-go` in the shell prompt.\n\nAliases are defined as comma-separated key value pairs, like this:\n\n```bash\npowerline-go ... -path-aliases \\$GOPATH/src/github.com=@GOPATH-GH,\\~/work/projects/foo=@FOO,\\~/work/projects/bar=@BAR\n```\n\nNote that you should use `~` instead of `/home/username` when specifying the\npath. Also make sure to escape the `~` character. Otherwise your shell will\nperform interpolation on it before `powerline-go` can see it!\n\n### Duration\n\nThe duration segment requires some assistance from the shell.  The shell must have a hook that gets executed immediately before the command.\n\n#### Bash\n\nBash 4.4 includes an easy way to get a start-time, using `$PS0`.  However, not all operating systems come with a sufficiently recent version of Bash installed.  This example only has seconds precision.  Add or modify your `.bashrc` file to include the following:\n\n```bash\nINTERACTIVE_BASHPID_TIMER=\"/tmp/${USER}.START.$$\"\n\nPS0='$(echo $SECONDS \u003e \"$INTERACTIVE_BASHPID_TIMER\")'\n\nfunction _update_ps1() {\n  local __ERRCODE=$?\n\n  local __DURATION=0\n  if [ -e $INTERACTIVE_BASHPID_TIMER ]; then\n    local __END=$SECONDS\n    local __START=$(cat \"$INTERACTIVE_BASHPID_TIMER\")\n    __DURATION=\"$(($__END - ${__START:-__END}))\"\n    rm -f \"$INTERACTIVE_BASHPID_TIMER\"\n  fi\n\n  PS1=\"$($GOPATH/bin/powerline-go -modules duration -duration $__DURATION -error $__ERRCODE -shell bash)\"\n}\n\nif [ \"$TERM\" != \"linux\" ] \u0026\u0026 [ -f \"$GOPATH/bin/powerline-go\" ]; then\n  PROMPT_COMMAND=\"_update_ps1; $PROMPT_COMMAND\"\nfi\n```\n\n#### Zsh\n\nUsing `$EPOCHREALTIME` requires loading the 'datetime' module in your `.zshrc` file, for example:\n\n```bash\nzmodload zsh/datetime\n\nfunction preexec() {\n  __TIMER=$EPOCHREALTIME\n}\n\nfunction powerline_precmd() {\n  local __ERRCODE=$?\n  local __DURATION=0\n\n  if [ -n $__TIMER ]; then\n    local __ERT=$EPOCHREALTIME\n    __DURATION=\"$(($__ERT - ${__TIMER:-__ERT}))\"\n  fi\n\n  PS1=\"$(powerline-go -modules duration -duration $__DURATION -error $__ERRCODE -shell zsh)\"\n  unset __TIMER\n}\n```\n\nIf the 'datetime' module is unavailable or unwanted, you may replace `$EPOCHREALTIME` with `$SECONDS`, at the loss of precision.\n\n#### Fish\n\nThe fish prompt, in `~/.config/fish/config.fish`, will require a minimum of changes, as Fish automatically provides `$CMD_DURATION`, although with only milliseconds accuracy.\n\n```bash\nfunction fish_prompt\n    set duration (math -s6 \"$CMD_DURATION / 1000\")\n    $GOPATH/bin/powerline-go -modules duration -duration $duration -error $status -shell bare\nend\n```\n\n## License\n\n\u003e This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\u003e \n\u003e This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\u003e \n\u003e You should have received a copy of the GNU General Public License along with this program. If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjanne%2Fpowerline-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustjanne%2Fpowerline-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustjanne%2Fpowerline-go/lists"}