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

newline segment not useful anywhere else than at the end #42

Open
thmxv opened this issue Jul 5, 2021 · 0 comments
Open

newline segment not useful anywhere else than at the end #42

thmxv opened this issue Jul 5, 2021 · 0 comments

Comments

@thmxv
Copy link

thmxv commented Jul 5, 2021

The current newline segment does 2 things, it adds a newline but it also adds the $/# 'prompt character'; which renders it useless for use at the start or in the middle of a prompt. To work around those issue I had to create 2 custom segments of my own, one for just a newline and one for just the prompt character. However those rely on un-documented private implementation details of trueline and I would prefer if they were included upstream. I think replacing the current newline segment by those 2 new segments would give more flexibility for all users.

_trueline_my_newline_segment() {
    local fg_color="$1"
    local bg_color="$2"
    local font_style="$3"
    local segment="$(_trueline_separator default_bg)"
    segment+="\n"
    PS1+="$segment"
    unset _last_color
}

_trueline_prompt_char_segment() {
    local fg_color="$1"
    local bg_color="$2"
    local font_style="$3"
    local is_root="$(_trueline_is_root)"
    local newline_symbol="${TRUELINE_SYMBOLS[newline]}"
    if [[ -n "$is_root" ]]; then
        local newline_symbol="${TRUELINE_SYMBOLS[newline_root]}"
    fi
    local segment="$(_trueline_separator)"
    segment+="$(_trueline_content "$fg_color" "$bg_color" "$font_style" " $newline_symbol ")"
    PS1+="$segment"
    _trueline_record_colors "$fg_color" "$bg_color" "$font_style" true
}
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

1 participant