Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-line shell #462

Closed
treyhunner opened this issue Apr 24, 2013 · 16 comments
Closed

multi-line shell #462

treyhunner opened this issue Apr 24, 2013 · 16 comments

Comments

@treyhunner
Copy link
Contributor

To achieve a two-line shell prompt I tried adding the following to "segment_data" for the shell configuration but it resulted in the triangle being placed on the next line.

    "cwd": {
        "after": "\n"
    }

Result:

Selection_029

@ZyX-I
Copy link
Contributor

ZyX-I commented May 6, 2013

I can deduce some hacks to make it work, but here is another proposal: use

# Theme file
{
    "segments": {
        "above": [
            {
                "left": [
                    # First line left segments
                ],
                "right": [
                    # First line right segments
                ]
            },
            {
                # Same for second line
            }
        ],
        "left": [
            # Usual last line segments
        ],
        "right": [
            # Usual last line right segments
        ]
    }
} 

(used YAML syntax to allow comments) where output will look like

First line left segments >   < First line right segments
Second line left segments >  < Second line right segments
Left segments > Typed text               < Right segments

@Lokaltog, how does this feel?

@Lokaltog
Copy link
Member

Lokaltog commented May 6, 2013

It could work pretty well. I think a more elegant solution could be to just have segments be a list, and each item in the list is an object which represents a line with the usual left/right keys. What do you think? It may be less obvious how it works without reading the docs (I can imagine users seeing the list and thinking each item is a segment and not a line), but not sure if that would be a huge problem.

@ZyX-I
Copy link
Contributor

ZyX-I commented May 6, 2013

There are two reasons why I have it this way:

  1. In any renderer but *sh ones† all lines except the last one must be ignored. This makes some line obviously special, but not enough to prefer my variant (you just warn and ignore all lines but some of them; not necessary last one).
  2. In *sh renderers last line is special for another reason: it has cursor and space for typing text inbetween.

This way it would be better to somehow select last line, I prefer the above. We are still not having configuration proposed previously (don’t remember where) about reserving some width for typed text (neither we have working truncation in shells: because sides are computed separately). It would be natural if option for this only existed in a special line and unnatural if it was valid only for last one.

† Unless we want to support multiline statusline patch that is created by some Japanese (AFAIR) vim user group.


By the way, there is a way to display prompt below cursor, though I guess there will be big problems with rendering (zsh also has a bunch of data like completion to display below prompt and it is needless to say you can easily write script that extends on more then one line).

@Lokaltog
Copy link
Member

Lokaltog commented May 7, 2013

You make a good point, I agree with your initial suggestion.

@gotgenes
Copy link

It seems like @treyhunner's solution for a separate line for the prompt no longer works. Here is the minimal configuration I used to test:

{
    "default_module": "powerline.segments.common",
    "segment_data": {
        "cwd": {
            "after": "\n$ "
        }
    },
    "segments": {
        "left": [
            {
                "name": "cwd"
            }
        ]
    }
}

Here is the result on the command line:

screen shot 2014-06-22 at 3 13 37 pm

I do not understand why the control-J (^J) character is in there.

@ZyX-I
Copy link
Contributor

ZyX-I commented Jun 22, 2014

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On June 23, 2014 2:15:13 AM GMT+03:00, Chris Lasher notifications@github.com wrote:

It seems like @treyhunner's solution for a separate line for the prompt
no longer works. Here is the minimal configuration I used to test:

{
  "default_module": "powerline.segments.common",
  "segment_data": {
      "cwd": {
          "after": "\n$ "
      }
  },
  "segments": {
      "left": [
          {
              "name": "cwd"
          }
      ]
  }
}

Here is the result on the command line:

screen shot 2014-06-22 at 3 13 37 pm

I do not understand why the control-J (^J) character is in there.


Reply to this email directly or view it on GitHub:
#462 (comment)

That solution was exploiting a bug that is no longer present. And you are wrong: CTRL-J character is not present there: control characters are not displayed in the terminal.

If you are asking why NL is replaced with '^J' then the answer is simple: because NL is CTRL-J.
-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1

iQJNBAEBCgA3BQJTp1t/MBwfMDI7PjIgHTg6PjswOSAQOzU6QTA9NEA+MjhHIDxr
cC1wYXZAeWFuZGV4LnJ1PgAKCRBu+P2/AXZZIiQvD/9S6V8qIfzstsqTStAQrs4t
gSTaFepaQFy9dBxaGch313+hnfL575KocIwYcvfxKhLfqf6Dy7a+TLtto26DkYYw
lL7Clyjp5vGE6OdzxMQnNjaSpmWUiYYS8UM20pIu3Ejq7rmXAROIqkY7LCRRpbQi
2r7CQzlUQsdjeUz0I8csb5Q4vKDBLy8vTAzcPtcxU8aGHbMoTlHDbiWBkskCf5e8
mAyO2+Ij0Uarw9AhVyyUPNVwF5W9G01wCzmjsS6W6mAD3Tv/K6zeKJXtfhdWiOfi
YJmdi1qU4DiAKJ4/USRidAlm8bFfRUbstSzEwc5HoqyMwz9XD6j77IskOIvDjvqA
Qi/i9EFhge8s654FsJmCil1LOLqLc8bDGHvC7uipreozTj/UT5w6hKrf1iHDrv/d
t+kD2rOlX7tftp82RTvzugtPiFBWssOxogM58w5xjL5YOkCIFH6HmOqLnZ8Xui8z
A+qcyRuMKWRyqzSlTRTAlwYYRvFVOUbh3K2iPE0S87XU5Tgfy9iZusdkVTS9/rat
/eIajqk38VZ392fuY9dQAthC0RD6VJ5eqXf+RRNjyRtM1QAUEdMEWlEImf052HTU
zhQXHZVvwoMccSWP0vOA7kylmi0GouPai6vL1Vxs0/6h3BTdn2p5uuPV0vbwiRol
lX/QG9k137hs0hDJs/b7ng==
=AleT
-----END PGP SIGNATURE-----

@gotgenes
Copy link

That solution was exploiting a bug that is no longer present.

There is no mention of the bug or its side effect anywhere else in this issue. That's fine though. So what's the new way to tell Powerline's shell component, "break the line"?

I want to put my prompt on a separate line than the information in the Powerline segments, as described at http://agperson.com/entry/4081. How do I do this, if the newline in "after" is now considered a bug exploit?

And you are wrong: CTRL-J character is not present there: control characters are not displayed in the terminal.

Fine, Powerline displays a "caret followed by a capital J", not a literal "Control-J", in lieu of a newline character. Based on the existing documentation I had to find by web searches, one of which led me to here, "caret followed by a capital J" was not the expected behavior.

@ZyX-I
Copy link
Contributor

ZyX-I commented Jun 23, 2014

There is no mention of the bug or its side effect anywhere else in this issue. That's fine though. So what's the new way to tell Powerline's shell component, "break the line"?

If there was this issue would be closed. Currently there is no way to have multiline prompt.

@ZyX-I
Copy link
Contributor

ZyX-I commented Jun 23, 2014

@gotgenes Check out new multiline-prompt branch in git://github.com/ZyX-I/powerline.

@ZyX-I
Copy link
Contributor

ZyX-I commented Jun 23, 2014

Note: I was testing my branch with

{
    "default_module": "powerline.segments.common",
    "segment_data": {
        "hostname": {
            "before": "",
            "args": {
                "only_if_ssh": true
            }
        },
        "virtualenv": {
            "before": ""
        },
        "branch": {
            "before": ""
        }
    },
    "segments": {
        "above": [
            {
                "left": [
                    {
                        "name": "cwd"
                    },
                    {
                        "type": "string",
                        "highlight_group": "cwd",
                        "draw_soft_divider": false,
                        "draw_hard_divider": false,
                        "width": "auto"
                    }
                ],
                "right": [
                    {
                        "name": "user"
                    }
                ]
            }
        ],
        "left": [
            {
                "module": "powerline.segments.shell",
                "name": "mode"
            },
            {
                "name": "hostname"
            },
            {
                "name": "user"
            },
            {
                "name": "virtualenv"
            },
            {
                "name": "cwd",
                "args": {
                    "use_path_separator": true,
                    "ellipsis": "",
                    "dir_limit_depth": 3
                }
            },
            {
                "module": "powerline.segments.shell",
                "name": "jobnum"
            }
        ],
        "right": [
            {
                "module": "powerline.segments.shell",
                "name": "last_pipe_status"
            },
            {
                "name": "branch"
            }
        ]
    }
}

in ${XDG_CONFIG_HOME:-$HOME/.config}/powerline/themes/shell/default.json.

@gotgenes
Copy link

Why make "above" a special case; why not just make segments itself an array with objects containing "left" and/or "right"? Objects are rendered in order of appearance in the array as separate lines, from first to last.

Using your example above:

    "segments": [
        {
            "left": [
                {
                    "name": "cwd"
                },
                {
                    "type": "string",
                    "highlight_group": "cwd",
                    "draw_soft_divider": false,
                    "draw_hard_divider": false,
                    "width": "auto"
                }
            ],
            "right": [
                {
                    "name": "user"
                }
            ]
        },
        {
            "left": [
                {
                    "module": "powerline.segments.shell",
                    "name": "mode"
                },
                {
                    "name": "hostname"
                },
                {
                    "name": "user"
                },
                {
                    "name": "virtualenv"
                },
                {
                    "name": "cwd",
                    "args": {
                        "use_path_separator": true,
                        "ellipsis": "…",
                        "dir_limit_depth": 3
                    }
                },
                {
                    "module": "powerline.segments.shell",
                    "name": "jobnum"
                }
            ],
            "right": [
                {
                    "module": "powerline.segments.shell",
                    "name": "last_pipe_status"
                },
                {
                    "name": "branch"
                }
            ]
        }
    ]

@ZyX-I
Copy link
Contributor

ZyX-I commented Jun 23, 2014

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On June 23, 2014 10:38:10 AM GMT+03:00, Chris Lasher notifications@github.com wrote:

What "above" being a special case, why not just make segments itself an
array with objects containing "left" and/or "right"? Objects are
rendered in order of appearance in the array as separate lines, from
first to last.

You should read this issue from top, your question was already answered.

Using your example above:

   "segments": [
       {
           "left": [
               {
                   "name": "cwd"
               },
               {
                   "type": "string",
                   "highlight_group": "cwd",
                   "draw_soft_divider": false,
                   "draw_hard_divider": false,
                   "width": "auto"
               }
           ],
           "right": [
               {
                   "name": "user"
               }
           ]
       },
       {
           "left": [
               {
                   "module": "powerline.segments.shell",
                   "name": "mode"
               },
               {
                   "name": "hostname"
               },
               {
                   "name": "user"
               },
               {
                   "name": "virtualenv"
               },
               {
                   "name": "cwd",
                   "args": {
                       "use_path_separator": true,
                       "ellipsis": "…",
                       "dir_limit_depth": 3
                   }
               },
               {
                   "module": "powerline.segments.shell",
                   "name": "jobnum"
               }
           ],
           "right": [
               {
                   "module": "powerline.segments.shell",
                   "name": "last_pipe_status"
               },
               {
                   "name": "branch"
               }
           ]
       }
   ]

Reply to this email directly or view it on GitHub:
#462 (comment)

-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1

iQJNBAEBCgA3BQJTp9p+MBwfMDI7PjIgHTg6PjswOSAQOzU6QTA9NEA+MjhHIDxr
cC1wYXZAeWFuZGV4LnJ1PgAKCRBu+P2/AXZZIr45EADM3dVGi1ryTRubE5c7SJmD
cvE4mSg/4TXTRPQcfCUxcIYN9fq8tF7FRSx9lWa7C3SJ/RIF6mBm0z1wQopx9CHo
UbjrMAW23JEXsJRMVyg8Jzmk5YKrUJMBa1W507y3DMw+6Vhm71Kw3yQKFsR/vNNG
6dW0dXpm22qXCSuT3aX+6ACWLjuHbGVrLEhbG4AF+jrakrO9M/6jbDPU97pkmh20
0TCcF177juhZ+ssaN2FZQ7NRGgdVg9VFw5eEisheQTVLiZ+YPUL3kF5k8PM+mEc/
gjLCGIdAEoAjGLbMx7DAqI4X1gJ57Z28vcLF4FzbOn2yCxhZg8X2gvG3TePx7vkd
3nWN67ct+FwnI5C5oIEF6vJuw1zBbMuyrizqHljXuHp3yRzUNBq3En6EnpkXnzXC
lY4pJ9/nKmSFSY0cj6gh94qND3/koWPoVmu4V0r3GFEzyWM1KtAo86dRUiIbG8BD
GjDucOqJrA//LrRavezhe4JXzH06z5cbZ3d0npydBd+E4USe/dxwNv8bbDdAnI2Q
5wiC1oXEUdEmXBz3HsSA6pQ+Kd2seOldAqZyz2oiJZB9Y+DoDaeyawAvRxNBS3xe
uBdLuAvjuo/XeSUxgue+wNcoWKtnNLJ4PVGJjMsFJwI6fOnRZZG1wAsuVzi77K2h
arcazcmqTjRAyel6sGuJtw==
=4r6h
-----END PGP SIGNATURE-----

@gotgenes
Copy link

Fair enough.

@ZyX-I ZyX-I mentioned this issue Jun 23, 2014
11 tasks
@ZyX-I ZyX-I added this to the Initial release milestone Jun 23, 2014
ZyX-I added a commit to ZyX-I/powerline that referenced this issue Jun 24, 2014
Support is not mirrored in shell bindings yet
@ZyX-I ZyX-I closed this as completed in 35522b1 Jun 24, 2014
@madpipeline
Copy link

I've looked and looked, and can't for the life of me figure out how can I have this on 2 lines.
Can you please provide a small example ?

@yongjhih
Copy link

yongjhih commented Nov 6, 2015

https://github.com/yongjhih/rc/blob/master/.config/powerline/themes/shell/default.json for example.

@madpipeline
Copy link

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants