tide
tide copied to clipboard
Add transient prompt feature
Is your feature request related to a problem? Please describe
A multi-line prompt is nice to use, but takes up a ton of scroll-back history.
Describe the solution you'd like
The prompt should optionally change right before hitting enter to become one line. Powerlevel10k has this feature and it has been requested in the past.
This would be sick!
Yes, please!
for visibility, see https://github.com/fish-shell/fish-shell/issues/7602 (and the linked PR which addresses it)
fish-shell/fish-shell#7602 is closed now. It references a PR that was merged and a couple other closed issues.
Does that mean this is waiting on a new release of fish-shell to be available? Does Tide
need https://github.com/fish-shell/fish-shell/milestone/30 to be completed for the transient prompt to work in Tide?
@ahillio Yes, Fish 3.4 would have to come out before Tide adds transient prompt. There is also a bug with repaints that would need to get fixed beforehand. Rest assured that Tide will add this feature when it is ready to be added π
Oh wow just found this issue. Yes please! π can't wait for fish 3.4 to be release ^^
@IlanCosman Soooooβ¦ Can this be implemented? π―
The bug mentioned by Ilan is still not fixed: https://github.com/fish-shell/fish-shell/issues/8418
I guess we need to wait for this one too :)
Interesting... that issue https://github.com/fish-shell/fish-shell/issues/8418 is referenced by another https://github.com/JanDeDobbeleer/oh-my-posh/issues/2467 and apparently oh-my-posh makes it possible to do a transient prompt in fish. I wonder if their method is something that could be used here?
Probably worth a shot.
π for this feature π
Still waiting for this one π
I wrote this, It works fine for me:
# rename fish_prompt to __transient_fish_prompt
if not type --query __transient_fish_prompt
and type --query fish_prompt
functions --copy fish_prompt __transient_fish_prompt
functions --erase fish_prompt
end
# rename fish_right_prompt to __transient_fish_right_prompt
if not type --query __transient_fish_right_prompt
and type --query fish_right_prompt
functions --copy fish_right_prompt __transient_fish_right_prompt
functions --erase fish_right_prompt
end
function ___default_transient_prompt
printf (set_color 5FD700)"β― "(set_color normal)
end
function ___reset_pipestatus
return $argv[1]
end
set --global TRANSIENT normal
set --global TRANSIENT_RIGHT normal
function fish_prompt
_transient_pipestatus=$pipestatus _transient_status=$status if test "$TRANSIENT" = normal
if type --query __transient_fish_prompt
___reset_pipestatus $_transient_pipestatus
__transient_fish_prompt
else
___default_transient_prompt
end
else
printf \e\[0J # clear from cursor to end of screen
if type --query transient_prompt_func
transient_prompt_func
else
___default_transient_prompt
end
set --global TRANSIENT normal
set --global TRANSIENT_RIGHT transient
commandline --function repaint
end
end
function fish_right_prompt
if test "$TRANSIENT_RIGHT" = transient
set --global TRANSIENT_RIGHT normal
commandline --function repaint
return 0
end
_transient_pipestatus=$pipestatus _transient_status=$status if test "$TRANSIENT_RIGHT" = normal
if type --query __transient_fish_right_prompt
___reset_pipestatus $_transient_pipestatus
__transient_fish_right_prompt
end
end
end
# transience related functions
function reset-transient --on-event fish_postexec
set --global TRANSIENT normal
set --global TRANSIENT_RIGHT normal
end
function transient_execute
set --global TRANSIENT transient
set --global TRANSIENT_RIGHT transient
if test "$(commandline -b)" != "" # fix empty enter
and commandline --paging-full-mode # Evaluates to true if the commandline is showing pager contents, such as tab completions and all lines are shown (no β<n> more rowsβ message).
set --global TRANSIENT normal
end
commandline --function repaint execute
end
function ctrl_c_transient_execute
set --global TRANSIENT transient
if test "$(commandline -b)" = ""
commandline --function repaint execute
return 0
end
commandline --function repaint cancel-commandline kill-inner-line repaint-mode
end
bind -M insert \r transient_execute
bind -M insert \cc ctrl_c_transient_execute
I wrote this, It works fine for me:
if not type --query __fish_prompt functions --copy fish_prompt __fish_prompt functions --erase fish_prompt end function fish_prompt set --function default_prompt (set_color 5FD700)"β― "(set_color normal) if test "$TRANSIENT" = 1 or test "$TRANSIENT" = 2 printf \e\[0J # clear from cursor to end of screen if type --query transient_prompt_func transient_prompt_func else printf $default_prompt end if test "$TRANSIENT" = 2 set --global TRANSIENT 0 commandline --function repaint end else if type --query __fish_prompt __fish_prompt else printf $default_prompt end end end # transience related functions function reset-transient --on-event fish_postexec set --global TRANSIENT 0 end function transient_execute if commandline --is-valid set --global TRANSIENT 1 commandline --function repaint else if test "$(commandline -b)" = "" # fix empty enter set --global TRANSIENT 2 commandline --function repaint else set --global TRANSIENT 0 end commandline --function execute end bind -M insert \r transient_execute # when enable vi keybinding use this bind # bind \r transient_execute # disable vi keybinding use this bind
This is not working for me. I'm using macOS. I see no difference.
I'm using MacOS. @SolidRhino the last line is important - if you are not using vi keybinding - you should swap comments and it would work as a Charm.
The other problem is about right_prompt - @zzhaolei do you know if it could be possible to remove right prompt as well?
@SolidRhino try this
@zzhaolei
The last lines of the code are now:
#bind -M insert \r transient_execute
#bind -M insert \cc ctrl_c_transient_execute
bind \r transient_execute
bind \cc ctrl_c_transient_execute
But still have this prompt:
This is literary the oldest open issue and so far lots of problems had to be solved to reach this state. now that https://github.com/IlanCosman/tide/issues/85#issuecomment-1409875980 works too, can we expect a PR :)
This is literary the oldest open issue and so far lots of problems had to be solved to reach this state. now that #85 (comment) works too, can we expect a PR :)
@Naadiyaar Sure, cooked something up. Try the transient-prompt
branch and set -U tide_transient_enabled true
.
This is literary the oldest open issue and so far lots of problems had to be solved to reach this state. now that #85 (comment) works too, can we expect a PR :)
@Naadiyaar Sure, cooked something up. Try the
transient-prompt
branch andset -U tide_transient_enabled true
.
Awesome, tried it right now and it works flawlessly with icons, frames, right prompt... enabled, good work.
it works flawlessly with icons, frames, right prompt...
Same here, thanks for working on this! I'll report any issues here should I run into them.
v6 released