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

I have no idea where to change the settings for shell #22

Open
voltumna opened this issue Mar 13, 2022 · 2 comments
Open

I have no idea where to change the settings for shell #22

voltumna opened this issue Mar 13, 2022 · 2 comments

Comments

@voltumna
Copy link

Dear all,
I have installed powerline via
sudo apt install powerline powerline-fonts powerline-gitstatus
because the other way, via github had issues like it could not find the ' ' command.

Funnily enough, the vim I have has its own implementation of powerline, and your docs show how to change the separators and that works well. But for the shell version, don't even know what to change, you mention the patched element, but not the file it has to go to.

I tried to search online, and found this article: powerline/powerline#20
where it shows how to change the separators, but again, to no avail, as you will see in the end notes of the case (I updated a close case, silly me).

Any help would be appreciated, I am going mad wasting hours on hours on this.

Thanks

@P-Louw
Copy link

P-Louw commented Dec 30, 2022

Hi @voltumna,
This might be a bit late but leaving this also as reference for future readers.

To try and consolidate vim. i3 and shell I recently swapped to powerline from powerline-shell. I ran into a few issues including this one. The docs contain a lot of info but it isn't quite straightforward in how the json is structured as a whole.

If you want to set dividers (separators) you should apply the changes to the json file in the user config file in themes. Be sure to apply it to the json file corresponding to the current theme chosen in the segment config json.

For example after installing on fedora from the repos powerline configs are stored in etc. So I copy those to a new user conf directory.

# Copy app config dir to user home for changes and merging by app:
cp -r /etc/xdg/powerline/ ~/.config/

Now in my user config I will leave the segment themes as default.
So in ~/.config/powerline/config.json

"common": {
    "term_truecolor": true
},
"ext": {
    "shell": {
        "colorscheme": "default",
        "theme": "default",
    }
}

Now to apply the divider, the file you set it in has to match the theme field from the config above. So for this it would be ~/.config/powerline/themes/shell/default.json

{
    "dividers": {
        "left": {
            "hard": "|",
            "soft": "-"
        },
        "right": {
            "hard": "|",
            "soft": "-"
        }
    },
    "segments": {
        "left": [
            {
                "function": "powerline.segments.shell.cwd",
                "priority": 10,
                "args": {
                    "dir_limit_depth": 2,
                    "use_shortened_path": true
                }
            }
        ],
        "right": []
    }

Now reload the daemon.

powerline-daemon --reload

As for custom segments, notice how I used a arg field in the left field.
The fields in the arg block can be found in the signature description for segments in the docs.

Finally what might not be clear is the multiline setup using json. If you want multiline i.e. cursor on newline you can use the 'above' field. say I wanted all my segments above my input cursor.

{
    "dividers": {
        "left": {
            "hard": "",
            "soft": ""
        },
        "right": {
            "hard": "",
            "soft": ""
        }
    },
    "segments": {
        "above": [
            {
                "left": [
                    {
                        "function": "powerline.segments.shell.mode"
                    },
                    {
                        "function": "powerline.segments.common.net.hostname",
                        "priority": 10
                    },
                    {
                        "function": "powerline.segments.common.env.user",
                        "priority": 30
                    },
                    {
                        "function": "powerline.segments.common.env.virtualenv",
                        "priority": 50
                    },
                    {
                        "function": "powerline.segments.shell.cwd",
                        "priority": 10,
                        "args": {
                            "dir_limit_depth": 2,
                            "use_shortened_path": true
                        }
                    },
                    {
                        "function": "powerline.segments.shell.jobnum",
                        "priority": 20
                    },
                    {
                        "function": "powerline.segments.common.vcs.stash",
                        "priority": 50
                    },
                    {
                        "function": "powerline_gitstatus.gitstatus",
                        "priority": 40,
                        "args": {
                            "show_tag": "exact"
                        }
                    }
                ],
                "right": []
            }
        ],
        "left": [
            {
                "function": "powerline.segments.shell.last_pipe_status",
                "priority": 10
            },
            {
                "type": "string",
                "contents": "$ ",
                "highlight_groups": [
                    "continuation:current"
                ]
            }
        ],
        "right": []
    }
}

Notice how at first I wrap a 'left' and 'right' in a 'above' field and then outside of that another 'left' and 'right'.

For git I am using the gitstatus segment in the above config.

Hope this gives a few hints on making a complete config.

@voltumna
Copy link
Author

voltumna commented Jan 2, 2023

Thank you,
that really helped :)

Maurizio

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

No branches or pull requests

2 participants