@@ -4,12 +4,13 @@ A [Powerline](https://github.com/Lokaltog/vim-powerline) like prompt for Bash,
4
4
ZSH and Fish. Based on [ Powerline-Shell] ( https://github.com/banga/powerline-shell ) by @banga .
5
5
Ported to golang by @justjanne .
6
6
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 )
8
8
9
9
- Shows some important details about the git/hg branch (see below)
10
10
- Changes color if the last command exited with a failure code
11
11
- If you're too deep into a directory tree, shortens the displayed path with an ellipsis
12
12
- 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/ )
13
14
- Shows if you are in a [ nix] ( https://nixos.org/ ) shell
14
15
- It's easy to customize and extend. See below for details.
15
16
@@ -23,6 +24,7 @@ Ported to golang by @justjanne.
23
24
- [ ZSH] ( #zsh )
24
25
- [ Fish] ( #fish )
25
26
- [ Nix] ( #nix )
27
+ - [ PowerShell] ( #powershell )
26
28
- [ Customization] ( #customization )
27
29
- [ License] ( #license )
28
30
@@ -49,13 +51,15 @@ Each of these will have a number next to it if more than one file matches.
49
51
50
52
## Installation
51
53
54
+ Requires Go 1.15+
55
+
52
56
` powerline-go ` uses ANSI color codes, these should nowadays work everywhere,
53
57
but you may have to set your $TERM to ` xterm-256color ` for it to work.
54
58
55
59
If you want to use the "patched" mode (which is the default, and provides
56
60
improved UI), you'll need to install a powerline font, either as fallback,
57
61
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 ) .
59
63
Alternatively you can use "compatible" or "flat" mode.
60
64
61
65
### Precompiled Binaries
@@ -68,7 +72,7 @@ I provide precompiled binaries for x64 Linux and macOS in the
68
72
- Install (and update) the package with
69
73
70
74
``` bash
71
- go get -u github.com/justjanne/powerline-go
75
+ go install github.com/justjanne/powerline-go@latest
72
76
```
73
77
74
78
- 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
77
81
78
82
### Bash
79
83
80
- Add the following to your ` .bashrc ` (or ` .profile ` on Mac) :
84
+ Add the following to your ` .bashrc ` :
81
85
82
86
``` bash
83
87
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 "?"
85
96
}
86
97
87
98
if [ " $TERM " != " linux" ] && [ -f " $GOPATH /bin/powerline-go" ]; then
@@ -97,7 +108,14 @@ Add the following to your `.zshrc`:
97
108
98
109
``` bash
99
110
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 "?"
101
119
}
102
120
103
121
function install_powerline_precmd() {
@@ -109,7 +127,7 @@ function install_powerline_precmd() {
109
127
precmd_functions+=(powerline_precmd)
110
128
}
111
129
112
- if [ " $TERM " != " linux" ]; then
130
+ if [ " $TERM " != " linux" ] && [ -f " $GOPATH /bin/powerline-go " ] ; then
113
131
install_powerline_precmd
114
132
fi
115
133
```
@@ -120,7 +138,7 @@ Redefine `fish_prompt` in `~/.config/fish/config.fish`:
120
138
121
139
``` bash
122
140
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))
124
142
end
125
143
```
126
144
### Nix
@@ -142,16 +160,46 @@ if [ "$IN_NIX_SHELL" == "pure" ]; then
142
160
fi
143
161
```
144
162
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
+
145
191
## Customization
146
192
147
193
There are a few optional arguments which can be seen by running
148
194
` powerline-go -help ` . These can be used by changing the command you have set
149
195
in your shell’s init file.
150
196
151
197
```
152
- Usage of ./powerline-go:
198
+ Usage of powerline-go:
199
+ -alternate-ssh-icon
200
+ Show the older, original icon for SSH connections
153
201
-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).
155
203
-condensed
156
204
Remove spacing between segments
157
205
-cwd-max-depth int
@@ -162,7 +210,7 @@ Usage of ./powerline-go:
162
210
(default -1)
163
211
-cwd-mode string
164
212
How to display the current directory
165
- (valid choices: fancy, plain, dironly)
213
+ (valid choices: fancy, semifancy, plain, dironly)
166
214
(default "fancy")
167
215
-duration string
168
216
The elapsed clock-time of the previous command
@@ -174,9 +222,24 @@ Usage of ./powerline-go:
174
222
Exit code of previously executed command
175
223
-eval
176
224
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
177
236
-ignore-repos string
178
237
A list of git repos to ignore. Separate with ','.
179
238
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
180
243
-max-width int
181
244
Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem.
182
245
-mode string
@@ -185,11 +248,13 @@ Usage of ./powerline-go:
185
248
(default "patched")
186
249
-modules string
187
250
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.
189
253
(default "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root")
190
254
-modules-right string
191
255
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.
193
258
-newline
194
259
Show the prompt on a new line
195
260
-numeric-exit-codes
@@ -201,14 +266,16 @@ Usage of ./powerline-go:
201
266
Use '~' for your home dir. You may need to escape this character to avoid shell substitution.
202
267
-priority string
203
268
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 )
205
270
(default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path")
206
271
-shell string
207
272
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 ")
210
275
-shell-var string
211
276
A shell variable to add to the segments.
277
+ -shell-var-no-warn-empty
278
+ Disables warning for empty shell variable.
212
279
-shorten-eks-names
213
280
Shortens names for EKS Kube clusters.
214
281
-shorten-gke-names
@@ -217,19 +284,26 @@ Usage of ./powerline-go:
217
284
Always show the prompt indicator with the default color, never with the error color
218
285
-theme string
219
286
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 )
221
288
(default "default")
289
+ -trim-ad-domain
290
+ Trim the Domainname from the AD username.
222
291
-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.
224
293
(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
225
298
```
299
+
226
300
### Eval
227
301
228
302
If using ` eval ` and ` -modules-right ` is desired, the shell setup must be modified slightly, as shown below:
229
303
230
304
##### Bash
231
305
232
- Add the following to your ` .bashrc ` (or ` .profile ` on Mac) :
306
+ Add the following to your ` .bashrc ` :
233
307
234
308
``` bash
235
309
function _update_ps1() {
@@ -285,7 +359,7 @@ Aliases are defined as comma-separated key value pairs, like this:
285
359
``` bash
286
360
powerline-go ... -path-aliases \$ GOPATH/src/github.com=@GOPATH-GH,\~ /work/projects/foo=@FOO,\~ /work/projects/bar=@BAR
287
361
```
288
-
362
+
289
363
Note that you should use ` ~ ` instead of ` /home/username ` when specifying the
290
364
path. Also make sure to escape the ` ~ ` character. Otherwise your shell will
291
365
perform interpolation on it before ` powerline-go ` can see it!
362
436
363
437
## License
364
438
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