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 newline in PS1 #68599

Closed
wants to merge 1 commit into from
Closed

Remove newline in PS1 #68599

wants to merge 1 commit into from

Conversation

NilsIrl
Copy link
Member

@NilsIrl NilsIrl commented Sep 12, 2019

Motivation for this change

This newline has been present as far back as git allowed me to go in PS1 (7c93a71) (2008 more than 10 years ago).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@NilsIrl
Copy link
Member Author

NilsIrl commented Sep 12, 2019

cc @svanderburg

(put the newline according to git)

@lheckemann
Copy link
Member

lheckemann commented Sep 13, 2019

-1, though it's a purely personal preference so I won't insist if this is widely supported.

EDIT: there is a reason to have it, which is that commands that don't terminate their output with a newline don't mess up the prompt.

@NilsIrl
Copy link
Member Author

NilsIrl commented Sep 13, 2019

there is a reason to have it, which is that commands that don't terminate their output with a newline don't mess up the prompt.

While messing up all other commands.

The thing is that this is non standard. NixOS (from what I know) is the only distro that does this. Also I'm pretty sure that in Ubuntu, commands that finish without newlines aren't messed up, how do they do it?

EDIT: Ubuntu doesn't fix it (and no one has ever complained about it)

@Mic92
Copy link
Member

Mic92 commented Sep 13, 2019

While messing up all other commands.

The thing is that this is non standard. NixOS (from what I know) is the only distro that does this. Also I'm pretty sure that in Ubuntu, commands that finish without newlines aren't messed up, how do they do it?

zsh fixes that on its own, maybe bash also have an option for that?

@lheckemann
Copy link
Member

While messing up all other commands.

It doesn't mess anything up at all, just looks different.

@NilsIrl
Copy link
Member Author

NilsIrl commented Sep 13, 2019

there is a reason to have it, which is that commands that don't terminate their output with a newline don't mess up the prompt.

It doesn't mess anything up at all, just looks different.

Applies to both

@lheckemann
Copy link
Member

A non-newline-terminated command does mess up the prompt if the prompt doesn't start with a newline. To see what I mean, try printf " %.0s" $(seq $((COLUMNS - 5 ))), and compare behaviour afterwards with a newline in the prompt and without.

@NilsIrl
Copy link
Member Author

NilsIrl commented Sep 13, 2019

A non-newline-terminated command does mess up the prompt if the prompt doesn't start with a newline. To see what I mean, try printf " %.0s" $(seq $((COLUMNS - 5 ))), and compare behaviour afterwards with a newline in the prompt and without.

I think i would be nice to do it similarly to Ubuntu (if they actually have a way and I'm not just making things up) but the same applies:

It doesn't mess anything up at all, just looks different.

This is just a choice but I believe it is better to do what is "expected".

@JohnAZoidberg
Copy link
Member

Maybe you could mention it on Discourse and ask for people's opinions.
I don't really care either way, since I use fish and it does this:

$ echo "Foo"
Foo
$ echo -n "foo"
foo⏎                                                                                                                                                                                                                                           $

However when I use bash on other distros I'm sometimes confused where my PS1 indicator has gone when it's just at the end of a long line without \n.
So I concur with @lheckemann that I don't want my prompt messed up.

As you mentioned it has been like this for >10 years so I wouldn't change it willy nilly.

@edolstra
Copy link
Member

Indeed it has been this way since the start and I don't see a strong reason to change it. I prefer it this way since I think it makes bash a bit more readable by clearly separating command invocations. Obviously not everybody will agree but that's true for any default.

@edolstra edolstra closed this Feb 16, 2020
@NilsIrl NilsIrl deleted the patch-1 branch February 16, 2020 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants