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

fish: --info-right prompt degrades text selection by adding trailing whitespace #28

Open
isker opened this issue Feb 7, 2023 · 0 comments

Comments

@isker
Copy link

isker commented Feb 7, 2023

Relevant code:

# Print additional information inside a nix-shell environment
function fish_right_prompt
$(which nix-shell-info)
printf " "
end

Here's a copy-pasted terminal session involving different fish_right_prompts' effects on text selection. Highlight the entire code block and observe that the prompt line has a ton of trailing whitespace, depending on the value of fish_right_prompt.

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
~ λ echo "start with a shell without the prompt added by --info-right"
start with a shell without the prompt added by --info-right
~ λ 
~ λ function fish_right_prompt
    end
~ λ echo "notice that had no effect on text selection"
notice that had no effect on text selection
~ λ 
~ λ function fish_right_prompt
        printf " "
    end
~ λ echo "see how that makes the selection copy the entire line?  it's because it inserted a single-space right-prmopt instead of nothing"                                                                                                      
see how that makes the selection copy the entire line?  it's because it inserted a single-space right-prmopt instead of nothing
~ λ                                                                                                                                                                                                                                             
~ λ function fish_right_prompt                                                                                                                                                                                                                  
        nix-shell-info
    end
~ λ echo "nix-shell-info prints nothing by default, so text selection is still fine"
nix-shell-info prints nothing by default, so text selection is still fine
~ λ 
~ λ function fish_right_prompt
        nix-shell-info
        printf " "
    end
~ λ echo "here's the actual right prompt generated by any-nix-shell, just to illustrate"                                                                                                                                                        
here's the actual right prompt generated by any-nix-shell, just to illustrate

This trailing whitespace is really bothersome when copy/pasting from the terminal into, say... GitHub issue descriptions!

Either we should delete the printf " " entirely, or make it conditional on nix-shell-info outputting something.

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