0rax/fishline

Make fishline compatible for fish_right_prompt

0rax opened this issue · 6 comments

0rax commented

Are you guys interested by using fishline as a fish_right_prompt.

I made some test, and I dont know. I am not a fan of right prompt to be honest but I imagine that having the GIT or CLOCK segment at the right of a one line fishline setup (Without the N segment)
with it vanishing when you are too close could be a good idea.

Here is my test:
fishline_right

If you wanna test it youself here is the little code I used:

#!/usr/bin/env fish
# -*-  mode:fish; tab-width:4  -*-
function fish_right_prompt

    set_color yellow
    printf "\uE0B2"
    set_color black -b yellow
    printf " %s " (date "+%H:%M:%S")
    set_color normal -b normal

end

Thank you.

Do you use an other FLINE_PROMPT var?

Can you dynamicaly convert a "left" item into a "right" item?
I mean, is it possible to say to fishline that, if our segment is on the right, it must print first the triangle and then the content of the segment?

0rax commented

Making a left item available as a right one is pretty easy, it's just a tweak to the FLINT_CLOSE function.

The only real hassle is that fish_right_prompt is handled in a way that it's printed after fish_prompt, and so if you have a multi-line left prompt, the right prompt will begin to print a the last line of the prompt. I, personally, dont think that's a big problem considering the example: A big top line with a little second and then the right prompt.

The only thing is making the fishline function availlable as a right and left prompt.

I though of three solutions.

  • source $FLINE_PATH/fishline.fish will create and set the fish_prompt and fish_right_prompt function based on two variable FLINE_PROMPT and FLINE_RIGHT_PROMPT. I dont really like this option if you want to have a special prompt when you are in a particular context (ie: a tty)
  • fishline will take an optionnal argument -r telling it to use the prompt passed as argument as right prompt and will be used like that
function fish_prompt
    fishline -s $status PWD GIT N ROOT
end
function fish_right_prompt
   fishline -r -s $status CLOCK
end
  • Simply have two functions fishline and fishline_right and two variable FLINE_PROMPT and FLINE_RIGHT_PROMPT working the way it is now,

I really like the last two options, the second one is, I think the more idiomatic way to do it, the second one is the easiest to use.

The second solution will also be good to preview what a prompt will look like by calling the fishline function with the appropriate argument but will break compatibility with older version.

If you have any better idea let me know.

I think the second option is the best way to implement a right prompt. But what if we only use the right prompt? Does the input cursor will be aligned to the left side?

0rax commented

Late update on this, as I didnt really had time in the past 6 months.

For you question @hug33k: having only a fish_right_prompt will still make your command cursor aligned to the left of the terminal as you might expect.

As for this issue, I have been working on fishline v2.0.0 in the dev branch today: this version will include the possibility to create a fish_right_prompt using the 2nd option detailed above.

I put a great effort making this version pretty backward compatible with the older version of fishline so an update will not force you to make some configuration change.

More information about this new version can be found in commit b8df72a and commit 0fce382.

I will be glad if any of you can test this version before merging to master (especially on MacOSX).

Hi @0rax,
I will try to reinstall Fish on my Mac and test the new version soon.

0rax commented

This will be part of the v2.0.0 final release of fishline and is already availlable on the dev branch.

Closing the issue