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

Remove empty line #509

Closed
qazip opened this issue Nov 11, 2019 · 8 comments
Closed

Remove empty line #509

qazip opened this issue Nov 11, 2019 · 8 comments

Comments

@qazip
Copy link

qazip commented Nov 11, 2019

There is an empty line between subsequent prompts. This can be seen in the image that it is in the README. For example, there is a line between "Exit 1" and "~".

Is it possible to remove this line? I find it wastes to much space.

@PerBothner
Copy link

Note that with shell integration a terminal can use some other visual separator between commands, so the empty line is redundant.

@0xBADDCAFE
Copy link

0xBADDCAFE commented Jan 7, 2020

I locally patch like this:

diff --git a/pure.zsh b/pure.zsh
index ddb0e30..3dad87d 100644
--- a/pure.zsh
+++ b/pure.zsh
@@ -176,7 +176,7 @@ prompt_pure_preprompt_render() {
 
 	if [[ $1 == precmd ]]; then
 		# Initial newline, for spaciousness.
-		print
+		# print
 	elif [[ $prompt_pure_last_prompt != $expanded_prompt ]]; then
 		# Redraw the prompt.
 		prompt_pure_reset_prompt

It is prefer to keep current behavior for other users, so how about create new option value like PURE_STRIP_NEW_LINE ?

@sindresorhus
Copy link
Owner

#526 (comment)

@bishopb
Copy link

bishopb commented Jun 9, 2020

You can hack around pure's current opinion with a custom implementation of print:

print() {
  [ 0 -eq $# -a "prompt_pure_precmd" = "${funcstack[-1]}" ] || builtin print "$@";
}

This implementation of print masks the built-in. When print is called with zero arguments inside a function named prompt_pure_precmd it does nothing (instead of printing an empty line); otherwise it behaves exactly as the print built-in.

Put this in your .zshrc before initializing pure and you're good to go.

Future updates to how pure behaves may invalidate this hack. Caveat emptor.

@james-prado
Copy link

@bishopb Is there anyway to prevent the new line only when the terminal is cleared or when first opening the terminal?

When I open a new terminal this happens:
before_clear

The custom print() function works well, but I only want to run it when the terminal is first opened, or after running clear. Do you know how to do something like this?

@bishopb
Copy link

bishopb commented Nov 30, 2020

The custom print() function works well, but I only want to run it when the terminal is first opened, or after running clear. Do you know how to do something like this?

@james-prado, not easily: you'd have to provide context to that print function so that it was aware when it was called in those conditions. I'd probably approach it by using an environment variable to keep track of the state, making an alias for clear, checking for a login shell's command depth, etc. Pretty gnarly.

@james-prado
Copy link

@bishopb Thanks for the reply. Yea that's a fair bit to go through just to remove a new line. I've learned to live with it for now.

@LangLangBart
Copy link

Do you know how to do something like this?

Using @bishopb's function and a slightly modified function from stackoverflow this works for new tabs/windows, but not for clear.
Screenshot 2022-02-17 at 17 29 04

dapuru added a commit to dapuru/pure that referenced this issue Oct 18, 2024
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

7 participants