Two questions

111 views
Skip to first unread message

Guy Gascoigne-Piggford

unread,
Jul 26, 2017, 10:32:13 AM7/26/17
to powerline
1) Is there a way to change the shell prompt, either by a color or a symbol change to indicate that the user is running with elevated privileges.  The equivalent of switching from $ to # for instance.

2) Is there a way to insert a newline in the prompt? Specifically I want to put a newline before the final $ or #.

Thanks - Guy

Nikolay Aleksandrovich Pavlov

unread,
Jul 26, 2017, 12:52:51 PM7/26/17
to Guy Gascoigne-Piggford, powerline
2017-07-26 17:32 GMT+03:00 Guy Gascoigne-Piggford <guy.pi...@gmail.com>:
> 1) Is there a way to change the shell prompt, either by a color or a symbol
> change to indicate that the user is running with elevated privileges. The
> equivalent of switching from $ to # for instance.

It is already done by default by `powerline.segments.common.user`
segment, but detection is limited to “user is (not) root” via UID.

>
> 2) Is there a way to insert a newline in the prompt? Specifically I want to
> put a newline before the final $ or #.

It is possible, using “above” key in theme configuration. Original
issue: https://github.com/powerline/powerline/issues/462,
documentation: http://powerline.readthedocs.io/en/master/configuration/reference.html#config-themes-segments.

Also are you sure you are using powerline? By default there are no
“final $ or #” and while it is possible to do with a proper use of
text segments and colorscheme adjustments, it is rather tricky and
goes against the idea. Normally it just ends with a triangle.

>
> Thanks - Guy
>
> --
> You received this message because you are subscribed to the Google Groups
> "powerline" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to powerline-supp...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Guy Gascoigne-Piggford

unread,
Jul 26, 2017, 1:31:55 PM7/26/17
to powerline, guy.pi...@gmail.com
At least on Bash, 'above' doesn't appear to do anything.  My shell theme is:

{
"default_module": "powerline.segments.common",
"segments": {
"above": [
{
"left": [
{
"function": "powerline.segments.shell.mode",
"priority": 10
},
{
"function": "powerline.segments.common.net.hostname",
"args": {
"only_if_ssh": true,
"exclude_domain": true
},
"priority": 10
},
{
"function": "powerline.segments.common.env.user",
"priority": 30
},
{
"function": "powerline.segments.shell.cwd",
"args": {
"dir_shorten_len": 3,
"dir_limit_depth": 3,
"use_path_separator": true
},
"priority": 20
},
{
"function": "powerline_gitstatus.gitstatus",
"priority": 40
}
]
}
]
}
}

The superuser coloring doesn't appear to work, and I just tested with no local config installed (I moved ~/.config/powerline out of the way).

As for the terminal $ or #, yeah, I know it's not there, I was rather hoping that I could find a way to add it.  We end out with some pretty long branch names here and  it would be nice to avoid truncating them.  I guess the alternative would be to trim them too.

Guy

Nikolay Aleksandrovich Pavlov

unread,
Jul 26, 2017, 1:48:24 PM7/26/17
to Guy Gascoigne-Piggford, powerline
2017-07-26 20:31 GMT+03:00 Guy Gascoigne-Piggford <guy.pi...@gmail.com>:
> At least on Bash, 'above' doesn't appear to do anything. My shell theme is:

Did you restart the daemon? The above support in bash is being tested:
https://github.com/ZyX-I/powerline/blob/427b2e73623143072f20ffefbfb4f2f7280dc6c2/tests/test_shells/inputs/bash#L59.

>
> {
It works for me. Though there are ways to have superuser permissions
without UID=0, if this is the case it will not work.

Note that in root powerline should be using root’s config.

Guy Gascoigne-Piggford

unread,
Jul 26, 2017, 2:13:53 PM7/26/17
to Nikolay Aleksandrovich Pavlov, powerline
id returns a uid of zero.

And above does generate a prompt, it's just indistinguishable from the left one - so no new line at the end of the prompt.

Guy

Nikolay Aleksandrovich Pavlov

unread,
Jul 26, 2017, 2:22:47 PM7/26/17
to Guy Gascoigne-Piggford, powerline
2017-07-26 21:13 GMT+03:00 Guy Gascoigne-Piggford <g...@wyrdrune.com>:
> id returns a uid of zero.
>
> And above does generate a prompt, it's just indistinguishable from the left
> one - so no new line at the end of the prompt.

Ah, I get it. In the current state you should have actual left segment
to make it work, just above will not work because of how shell
constructs are processed (prompt is using `PS1="$(…)"` which swallows
all the trailing newlines).
Reply all
Reply to author
Forward
0 new messages