Most active commenters
  • acedTrex(4)

←back to thread

457 points benoitg | 24 comments | | HN request time: 1.338s | source | bottom
Show context
hiAndrewQuinn ◴[] No.44365512[source]
I like maximalist prompts, and indeed Starship is what Shell Bling Ubuntu [1] installs on a new dev machine. But they're not everyone's cup of tea.

If I wanted to recommend to someone the min-maxed, highest density thing they could add to their prompt, it would simply be the time your current prompt appeared + the amount of time the last command you ran took.

These two pieces of information together make it very easy for you (or your local sysadmin (or an LLM looking over your digital shoulder)) to piece together a log of exactly what happened when. This kind of psuedo-non-repudiation can be invaluable for debugging sessions when you least expect it.

This was a tip I distilled from Michael W. Lucas's Networking for System Administrators a few years ago, which remains my preferred recommendation for any developers looking to learn just enough about networking to not feel totally lost when talking to an actual network engineer.

Bonus nerd points if you measure time in seconds since the UNIX epoch. Very easy and fast to run time delta calculations if you do that:

    [0 1719242840] $ echo "foo"
    [0 1719242905] $ echo "fell asleep before hitting enter" && sleep 5
    [5 1719242910] $
[1]: https://github.com/hiAndrewQuinn/shell-bling-ubuntu
replies(6): >>44365588 #>>44366612 #>>44367092 #>>44368319 #>>44369209 #>>44369984 #
skydhash ◴[] No.44365588[source]
For personal workstation, the current directory is enough. Maybe I change the color based the status of the last command. That’s pretty much the only information I need before entering any command. Everything else can be accessed when I really need it.
replies(3): >>44365629 #>>44365734 #>>44365877 #
1. acedTrex ◴[] No.44365734[source]
You don't need to know what branch you're on before running commands? I cant tell you the number of times ive been on the wrong branch executing stuff.
replies(8): >>44366003 #>>44366505 #>>44366718 #>>44366786 #>>44367475 #>>44368214 #>>44368680 #>>44374337 #
2. zikduruqe ◴[] No.44366003[source]
For me the AWS integration is nice. That way I know what account I'm on, and what region among my dozens of windows.

For example:

    …/.config master on AWS_Prod (use2)
starship.toml:

    [aws]
    format = 'on [($profile )(\($region\) )]($style)'
    style = 'bold #B23D2F'
    symbol = " "  <- cloud symbol
    [aws.region_aliases]
    us-east-1 = 'use1'
    us-east-2 = 'use2'
replies(1): >>44366174 #
3. acedTrex ◴[] No.44366174[source]
Oh ya, for work the kubeconfig integration is absolutely essential, i bounce between local clusters and shared nonprod clusters all the time and while its not an outage to break the nonprods its going to annoy a lot of people so its nice to know which one is active.
4. alganet ◴[] No.44366505[source]
I literally use just PS1='$ '.

`git status` to know git stuff. `pwd` for the current working directory, etc

I also don't use aliases like `gs` or `..`

One good thing about having a very minimal setup is that you feel at home anywhere.

It wasn't always like this. I used many, many prompts and shell tools over the decades. The only tool that stood the test of time is tmux.

replies(4): >>44366597 #>>44366603 #>>44366634 #>>44371893 #
5. horsawlarway ◴[] No.44366597[source]
Same here. I definitely went through a powerline, alias, huge vimrc, etc phase, but it turns out just sticking to the base toolset is pretty handy.

I can sit down at (or ssh into) any machine and be basically just as productive, and it also turns out that I just always want to know more than nicely fits into the prompt anyways.

There's something to be said for accepting the defaults of a tool, and learning to use them well. Customization is powerful, but... I think most times it's not the right call until you're already an expert in the tool at hand.

6. ericmay ◴[] No.44366603[source]
Same here, I also find that aliases for speed introduce unnecessary complexity and mental overhead later on. It's not much, and for other people it doesn't matter or they have a different preference, but that's what I prefer.

Sort of contrary to that I really enjoy the maximalist shells. A computer should be fun to use!

replies(1): >>44368605 #
7. acedTrex ◴[] No.44366634[source]
See when I don't have a prompt I forget to run those things and just autopilot through a lot of commands before I realize Im on the wrong branch.

For example if I have say 3 worktrees open in 3 seperate tmux tabs and are context switching between them (very common when reviewing multiple PRs from my devs) Sometimes i will get the tabs mixed up, which worktree is where etc and just autopilot a bunch of commands meant for one tree into a different one and its quite annoying to clean up.

The prompt has generally stopped me from doing that.

replies(1): >>44366901 #
8. msgodel ◴[] No.44366718[source]
I just run git status manually, I always explicitly specify the branch when I do anything that touches a remote, everything else you can undo if you have to.
9. kccqzy ◴[] No.44366786[source]
I'm highly aware of which branch I'm on. Because it's because I don't use any scripts or automation that switches branches; I only ever switch branches manually so I have that awareness.
replies(2): >>44366924 #>>44367266 #
10. alganet ◴[] No.44366901{3}[source]
On tmux, I use split panels more often than tabs.

Usually, there will be from 2 to 8 panels of different sizes.

This gives me spacial short term memory: I know what each shell is by the panel position.

I can zoom on then to bring them full screen (ctrl+b z) if I'm going to do anything that requires more space, then zoom out to the panel arrangement when I'm done.

Sometimes I'll name prompts (eg `PS1='stg$ '`), specially when working with ssh, but that's rare.

What inspired me to work this way was this video on the acme editor: https://www.youtube.com/watch?v=dP1xVpMPn8M

11. fkyoureadthedoc ◴[] No.44366924[source]
I only switch branches manually too, but I work in many repos and come back to stuff after days sometimes.
replies(2): >>44368918 #>>44375513 #
12. slightwinder ◴[] No.44367266[source]
How well does this work when you work on multiple repos with longer pauses inbetween?

And the Branch is also an unintrusive reminder that you are in a path under versioncontrol.

replies(1): >>44368835 #
13. jt_b ◴[] No.44367475[source]
oh-my-zsh default prompt mode for git branches is for me! super clean. need to familiarize myself with some more of their shorthand commands.
14. freeopinion ◴[] No.44368214[source]
As a complete aside, and not to argue with you at all: I think it might change your life to take a good look at jj. I just mention this to try to be helpful to you.
15. gumbojuice ◴[] No.44368605{3}[source]
I don't use aliases, but abbreviations that expand to the actual full command. Helpful to type less and history has the exact.
replies(1): >>44376371 #
16. skydhash ◴[] No.44368680[source]
Manual git status is enough for me.
17. jonhohle ◴[] No.44368835{3}[source]
not op, but if I haven’t been in a working directory for a while, I always run `git status` anyway. Then I know the branch and any out of date files. I usually run `git pull —-rebase` and get everything back up to date. I try not to leave broken branches around, so It’s rare that knowing which branch I’m on is an issue.
18. gcarvalho ◴[] No.44368918{3}[source]
Even if I know my current branch, having my prompt show me untracked/uncommitted/unpushed changes helps to identify if something didn’t work because I’m in a dirty state, or if something I ran (unexpectedly) caused a dirty state.

For example, I don’t expect running scripts/build.sh to modify tracked files in the repo. Seeing part of the prompt go from “” to “?2!3” (two untracked, three changed files) makes that glaringly obvious.

19. 1vuio0pswjnm7 ◴[] No.44371893[source]
"The only tool that stood the test of time is tmux."

tmux comes from BSD rather thsn GNU/Linux, or Windows

What is the default shell in OpenBSD

starship does not support it

   starship init ksh

   ksh is not yet supported by starship.
   For the time being, we support the following shells:
   * bash
   * elvish
   * fish
   * ion
   * powershell
   * tcsh
   * zsh
   * nu
   * xonsh
   * cmd

   Please open an issue in the starship repo if you would like to see support for ksh:
   https://github.com/starship/starship/issues/new
20. setopt ◴[] No.44374337[source]
I guess it depends on your day job and workflow?

I’m a researcher and work on small projects with 1-3 people (most of the time it’s just me prototyping stuff alone). I then tend to work on a branch for weeks at a time, so the git branch provides very little information compared to the space it takes in a prompt.

If I was switching branches every 5min, it would be useful.

21. 0points ◴[] No.44375513{3}[source]
"git status" is all you need then.
replies(1): >>44377822 #
22. Bagged2347 ◴[] No.44376371{4}[source]
I like this. What do you use to accomplish this?
replies(1): >>44384439 #
23. acedTrex ◴[] No.44377822{4}[source]
Then you have to remember to run this regularly. Which i regularly forget in tmux autopilot mode. The prompt serves as one last headsup reminder. Even then sometimes I dont look at it and have to roll some stuff back
24. phatskat ◴[] No.44384439{5}[source]
I don’t know exactly what they’re referencing, but Zsh has something like that where you can expand eg filenames and paths from this unique bits.

So if you have

``` src/components/Button.vue src/components/ButtonGroup.vue ```

And you type `nvim s/c/G<Tab>` it’ll expand to the second file’s path.