Skip to content

Commit 01b7d30

Browse files
author
Gavino Felix
committed
update
1 parent 2d7fad1 commit 01b7d30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4359
-2264
lines changed

README.md

Lines changed: 99 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ A [Powerline](https://github.com/Lokaltog/vim-powerline) like prompt for Bash,
44
ZSH and Fish. Based on [Powerline-Shell](https://github.com/banga/powerline-shell) by @banga.
55
Ported to golang by @justjanne.
66

7-
![Solarized+Powerline](https://raw.github.com/justjanne/powerline-go/master/preview.png)
7+
![Solarized+Powerline](https://raw.github.com/justjanne/powerline-go/main/preview.png)
88

99
- Shows some important details about the git/hg branch (see below)
1010
- Changes color if the last command exited with a failure code
1111
- If you're too deep into a directory tree, shortens the displayed path with an ellipsis
1212
- Shows the current Python [virtualenv](http://www.virtualenv.org/) environment
13+
- Shows the current Ruby version using [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io/)
1314
- Shows if you are in a [nix](https://nixos.org/) shell
1415
- It's easy to customize and extend. See below for details.
1516

@@ -23,6 +24,7 @@ Ported to golang by @justjanne.
2324
- [ZSH](#zsh)
2425
- [Fish](#fish)
2526
- [Nix](#nix)
27+
- [PowerShell](#powershell)
2628
- [Customization](#customization)
2729
- [License](#license)
2830

@@ -49,13 +51,15 @@ Each of these will have a number next to it if more than one file matches.
4951

5052
## Installation
5153

54+
Requires Go 1.15+
55+
5256
`powerline-go` uses ANSI color codes, these should nowadays work everywhere,
5357
but you may have to set your $TERM to `xterm-256color` for it to work.
5458

5559
If you want to use the "patched" mode (which is the default, and provides
5660
improved UI), you'll need to install a powerline font, either as fallback,
5761
or by patching the font you use for your terminal: see
58-
[powerline-fonts](https://github.com/Lokaltog/powerline-fonts).
62+
[powerline-fonts](https://github.com/Lokaltog/powerline-fonts).
5963
Alternatively you can use "compatible" or "flat" mode.
6064

6165
### Precompiled Binaries
@@ -68,7 +72,7 @@ I provide precompiled binaries for x64 Linux and macOS in the
6872
- Install (and update) the package with
6973

7074
```bash
71-
go get -u github.com/justjanne/powerline-go
75+
go install github.com/justjanne/powerline-go@latest
7276
```
7377

7478
- By default it will be in `$GOPATH/bin`, if you want to change that, you can set
@@ -77,11 +81,18 @@ go get -u github.com/justjanne/powerline-go
7781

7882
### Bash
7983

80-
Add the following to your `.bashrc` (or `.profile` on Mac):
84+
Add the following to your `.bashrc`:
8185

8286
```bash
8387
function _update_ps1() {
84-
PS1="$($GOPATH/bin/powerline-go -error $?)"
88+
PS1="$($GOPATH/bin/powerline-go -error $? -jobs $(jobs -p | wc -l))"
89+
90+
# Uncomment the following line to automatically clear errors after showing
91+
# them once. This not only clears the error for powerline-go, but also for
92+
# everything else you run in that shell. Don't enable this if you're not
93+
# sure this is what you want.
94+
95+
#set "?"
8596
}
8697

8798
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
@@ -97,7 +108,14 @@ Add the following to your `.zshrc`:
97108

98109
```bash
99110
function powerline_precmd() {
100-
PS1="$($GOPATH/bin/powerline-go -error $? -shell zsh)"
111+
PS1="$($GOPATH/bin/powerline-go -error $? -jobs ${${(%):%j}:-0})"
112+
113+
# Uncomment the following line to automatically clear errors after showing
114+
# them once. This not only clears the error for powerline-go, but also for
115+
# everything else you run in that shell. Don't enable this if you're not
116+
# sure this is what you want.
117+
118+
#set "?"
101119
}
102120

103121
function install_powerline_precmd() {
@@ -109,7 +127,7 @@ function install_powerline_precmd() {
109127
precmd_functions+=(powerline_precmd)
110128
}
111129

112-
if [ "$TERM" != "linux" ]; then
130+
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
113131
install_powerline_precmd
114132
fi
115133
```
@@ -120,7 +138,7 @@ Redefine `fish_prompt` in `~/.config/fish/config.fish`:
120138

121139
```bash
122140
function fish_prompt
123-
eval $GOPATH/bin/powerline-go -error $status -shell bare
141+
eval $GOPATH/bin/powerline-go -error $status -jobs (count (jobs -p))
124142
end
125143
```
126144
### Nix
@@ -142,16 +160,46 @@ if [ "$IN_NIX_SHELL" == "pure" ]; then
142160
fi
143161
```
144162

163+
### Powershell
164+
165+
Redefine `prompt` function on your profile:
166+
167+
```powershell
168+
# Load powerline-go prompt
169+
function global:prompt {
170+
$pwd = $ExecutionContext.SessionState.Path.CurrentLocation
171+
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
172+
$startInfo.FileName = "powerline-go"
173+
$startInfo.Arguments = "-shell bare"
174+
$startInfo.Environment["TERM"] = "xterm-256color"
175+
$startInfo.CreateNoWindow = $true
176+
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
177+
$startInfo.RedirectStandardOutput = $true
178+
$startInfo.UseShellExecute = $false
179+
$startInfo.WorkingDirectory = $pwd
180+
$process = New-Object System.Diagnostics.Process
181+
$process.StartInfo = $startInfo
182+
$process.Start() | Out-Null
183+
$standardOut = $process.StandardOutput.ReadToEnd()
184+
$process.WaitForExit()
185+
$standardOut
186+
}
187+
```
188+
189+
Use `ProcessStartInfo` is needed to allow fill the enviromnet variables required by powerline-go.
190+
145191
## Customization
146192

147193
There are a few optional arguments which can be seen by running
148194
`powerline-go -help`. These can be used by changing the command you have set
149195
in your shell’s init file.
150196

151197
```
152-
Usage of ./powerline-go:
198+
Usage of powerline-go:
199+
-alternate-ssh-icon
200+
Show the older, original icon for SSH connections
153201
-colorize-hostname
154-
Colorize the hostname based on a hash of itself
202+
Colorize the hostname based on a hash of itself, or use the PLGO_HOSTNAMEFG and PLGO_HOSTNAMEBG env vars (both need to be set).
155203
-condensed
156204
Remove spacing between segments
157205
-cwd-max-depth int
@@ -162,7 +210,7 @@ Usage of ./powerline-go:
162210
(default -1)
163211
-cwd-mode string
164212
How to display the current directory
165-
(valid choices: fancy, plain, dironly)
213+
(valid choices: fancy, semifancy, plain, dironly)
166214
(default "fancy")
167215
-duration string
168216
The elapsed clock-time of the previous command
@@ -174,9 +222,24 @@ Usage of ./powerline-go:
174222
Exit code of previously executed command
175223
-eval
176224
Output prompt in 'eval' format.
225+
-git-assume-unchanged-size int
226+
Disable checking for changed/edited files in git repositories where the index is larger than this size (in KB), improves performance (default 2048)
227+
-git-disable-stats string
228+
Comma-separated list to disable individual git statuses
229+
(valid choices: ahead, behind, staged, notStaged, untracked, conflicted, stashed)
230+
-git-mode string
231+
How to display git status
232+
(valid choices: fancy, compact, simple)
233+
(default "fancy")
234+
-hostname-only-if-ssh
235+
Show hostname only for SSH connections
177236
-ignore-repos string
178237
A list of git repos to ignore. Separate with ','.
179238
Repos are identified by their root directory.
239+
-ignore-warnings
240+
Ignores all warnings regarding unset or broken variables
241+
-jobs int
242+
Number of jobs currently running
180243
-max-width int
181244
Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem.
182245
-mode string
@@ -185,11 +248,13 @@ Usage of ./powerline-go:
185248
(default "patched")
186249
-modules string
187250
The list of modules to load, separated by ','
188-
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
251+
(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)
252+
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.
189253
(default "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root")
190254
-modules-right string
191255
The list of modules to load anchored to the right, for shells that support it, separated by ','
192-
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
256+
(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)
257+
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.
193258
-newline
194259
Show the prompt on a new line
195260
-numeric-exit-codes
@@ -201,14 +266,16 @@ Usage of ./powerline-go:
201266
Use '~' for your home dir. You may need to escape this character to avoid shell substitution.
202267
-priority string
203268
Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','
204-
(valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)
269+
(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)
205270
(default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path")
206271
-shell string
207272
Set this to your shell type
208-
(valid choices: bare, bash, zsh)
209-
(default "bash")
273+
(valid choices: autodetect, bare, bash, zsh)
274+
(default "autodetect")
210275
-shell-var string
211276
A shell variable to add to the segments.
277+
-shell-var-no-warn-empty
278+
Disables warning for empty shell variable.
212279
-shorten-eks-names
213280
Shortens names for EKS Kube clusters.
214281
-shorten-gke-names
@@ -217,19 +284,26 @@ Usage of ./powerline-go:
217284
Always show the prompt indicator with the default color, never with the error color
218285
-theme string
219286
Set this to the theme you want to use
220-
(valid choices: default, low-contrast)
287+
(valid choices: default, low-contrast, gruvbox, solarized-dark16, solarized-light16)
221288
(default "default")
289+
-trim-ad-domain
290+
Trim the Domainname from the AD username.
222291
-truncate-segment-width int
223-
Minimum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it.
292+
Maximum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it.
224293
(default 16)
294+
-venv-name-size-limit int
295+
Show indicator instead of virtualenv name if name is longer than this limit (defaults to 0, which is unlimited)
296+
-vi-mode string
297+
The current vi-mode (eg. KEYMAP for zsh) for vi-module module
225298
```
299+
226300
### Eval
227301

228302
If using `eval` and `-modules-right` is desired, the shell setup must be modified slightly, as shown below:
229303

230304
##### Bash
231305

232-
Add the following to your `.bashrc` (or `.profile` on Mac):
306+
Add the following to your `.bashrc`:
233307

234308
```bash
235309
function _update_ps1() {
@@ -285,7 +359,7 @@ Aliases are defined as comma-separated key value pairs, like this:
285359
```bash
286360
powerline-go ... -path-aliases \$GOPATH/src/github.com=@GOPATH-GH,\~/work/projects/foo=@FOO,\~/work/projects/bar=@BAR
287361
```
288-
362+
289363
Note that you should use `~` instead of `/home/username` when specifying the
290364
path. Also make sure to escape the `~` character. Otherwise your shell will
291365
perform interpolation on it before `powerline-go` can see it!
@@ -362,6 +436,8 @@ end
362436

363437
## License
364438

365-
> 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.
366-
> 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.
367-
> You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
439+
> 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.
440+
>
441+
> 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.
442+
>
443+
> You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

0 commit comments

Comments
 (0)