Page MenuHomePhabricator

[Nix] Add m1 bash default prompt to list
AbandonedPublic

Authored by jon on Aug 11 2022, 10:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 11:22 AM
Unknown Object (File)
Sat, Nov 9, 2:54 AM
Unknown Object (File)
Sun, Nov 3, 7:45 PM
Unknown Object (File)
Sun, Nov 3, 7:44 PM
Unknown Object (File)
Sun, Nov 3, 7:26 PM
Unknown Object (File)
Oct 8 2024, 8:01 AM
Unknown Object (File)
Oct 8 2024, 1:12 AM
Unknown Object (File)
Oct 4 2024, 9:11 AM
Subscribers

Details

Reviewers
ashoat
abosh
Summary

Context: https://linear.app/comm/issue/ENG-1550#comment-f6df3682

Add Ashoat's default PS1, which seems to be the default for some m1 mac's.

Used my wife's m1 mac computer to see what her unadulterated ps1 was (she doesn't program), my intel mac, and my linux box to determine the 2 PS1's fro https://phab.comm.dev/D4790. But I guess MacOS has many different defaults depending on something I'm not sure of.

Test Plan
# Ensure that ~/.bashrc won't affect logic
# Should only be necessary if personally configured
[[ -f ~/.bashrc ]] && mv ~/.bashrc ~/.bashrc.bak

# from any branch
nix develop 'github.com:commE2E/comm?ref=jonringer/ashoat-ps1'

# Prompt should look decent

# restore old bashrc
[[ -f ~/.bashrc.bak ]] && mv ~/.bashrc{.bak,}

Same test plan for https://phab.comm.dev/D4790

Diff Detail

Repository
rCOMM Comm
Branch
jonringer/ashoat-ps1
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ashoat requested changes to this revision.Aug 12 2022, 6:43 AM

Not sure what you mean by "Ashoat's default PS1". This is what I set in my ~/.bash_profile: PS1="\u@\h [\w]$ "

Can you clarify more?

  1. Where is this "default PS1" coming from?
  2. Why is it necessary to check the default prompt? Is the goal to allow the user to override our default with their ~/.bash_profile?
This revision now requires changes to proceed.Aug 12 2022, 6:43 AM

This is what I set in my ~/.bash_profile: PS1="\u@\h [\w]$ "

Oh, if you set it, isn't that the prompt which you wanted to use?

I thought the goal was, "if someone has an opinionated prompt, just let them use it, but if they don't then give them much nicer one."

Setting the prompt to be something different communicates to me that is the intended way you want to use the shell. Who am I to overwrite your wishes?

Where is this "default PS1" coming from?

I nuked my ~/.bash{_profile,rc} with my own stuff which I'm familiar with, check my wife's mac to get the values I have populated there. I was under the impression that the PS1 you have right now was inherited. I'll abandon this.

Why is it necessary to check the default prompt?

It's a developer shell, some developers may already have a bash workflow they grok already. I don't think we should be unilaterally deciding what prompt they should be using. Just provide a better default.

Is the goal to allow the user to override our default with their ~/.bash_profile?

That was my intention. Especially on macos where it's pretty likely that people don't even try configuring bash, as zsh has been the default for a while now.

The original linear text was:

nix develop will drop you into a bash shell, which has a lackluster shell unless a user has modified it. The default bash shell on mac has \s-\v\$ as the prompt (PS1), which usually looks like bash-3.2$ . We could "upgrade" this into something much better looking

I guess I meant that to mean, "provide a better default"

ashoat requested changes to this revision.Aug 12 2022, 10:01 AM

I'm not sure you realized that the PS1 I quoted from my ~/.bash_profile above is not the one that is being used by Nix, and not the one you've added here

Setting the prompt to be something different communicates to me that is the intended way you want to use the shell. Who am I to overwrite your wishes?

Makes sense as an answer to 2, but I still need an answer to 1:

Where is this "default PS1" coming from?

This revision now requires changes to proceed.Aug 12 2022, 10:01 AM

Where is this "default PS1" coming from?

Are you talking about what is there already?

I got those from removing my ~/.bashrc and examining what was there. '\s-\v\$' was on my wife's m1 machine and my intel mac, %n@%m %1~ %# is what my linux produced, and looks like my m1 is also producing '\h:\W \u\$ '

jon retitled this revision from [Nix] Add another default prompt to list to [Nix] Add m1 bash default prompt to list.Aug 12 2022, 10:11 AM

Not sure why I'm getting different results everywhere

Still haven't answered my question. Where is \h:\W \u\$ coming from?

[10:07:47] jon@Jonathans-Mac-mini ~
$ mv ~/.bashrc ~/.bashrc.bak
# new terminal session
Jonathans-Mac-mini:~ jon$ echo "'$PS1'"
'\h:\W \u\$ '
ashoat requested changes to this revision.Aug 12 2022, 10:22 AM
This revision now requires changes to proceed.Aug 12 2022, 10:22 AM

I think @ashoat may have hit Request Changes after submitting his comment but not before you replied here, which is why this diff is in a weird state of you answered his question but received no response and instead got a request for revision.

I also share some of @ashoat's confusion as to where \h:\W \u\$ came from. After pasting it into this prompt generator, this is what I see:

image.png (462×1 px, 68 KB)

image.png (266×558 px, 20 KB)

So I have a visual understanding of what the prompt looks like, but because I don't really use bash on my Mac, I don't know if this is the default or not. @ashoat does use bash on Mac, but he has an opinionated PS1 (\u@\h [\w]$ ), so he probably didn't immediately recognize the default, either. Hence why he asked where \h:\W \u\$ came from.

Especially on macos where it's pretty likely that people don't even try configuring bash, as zsh has been the default for a while now.

This is true for me. I hardly touch bash on my M1 machine, and wasn't really familiar with the default bash prompt for MacOS since I use zsh.

I think your latest comment showing terminal output is enough to convince me that \h:\W \u\$ is a default for bash on MacOS, and should be added as a prompt that we should check for to make sure the user has a different PS1. But next time, please provide some of this clarifying information in the diff summary or test plan. Like any sort of concrete evidence to show that \h:\W \u\$ is the default (command line output, pictures, etc.). The diff should be small, but the summary and test plan should be descriptive.

jon edited the test plan for this revision. (Show Details)
jon removed a subscriber: adrian.

I think your latest comment showing terminal output is enough to convince me that \h:\W \u\$ is a default for bash on MacOS, and should be added as a prompt that we should check for to make sure the user has a different PS1.

This is a continuation of D4790, where I only captured 2 potential defaults, \h:\W \u\$ is a third.

But next time, please provide some of this clarifying information in the diff summary or test plan.

Fair enough, it was in response to https://linear.app/comm/issue/ENG-1550#comment-f6df3682 where @ashoat mentioned that powerline wasn't being triggered. Although it was being triggered on my intel mac.

jon edited the summary of this revision. (Show Details)

I removed this in D4844, and instead prompt user for preference.