Most active commenters
  • hiAndrewQuinn(6)
  • bayindirh(6)
  • acedTrex(4)
  • stirfish(3)

←back to thread

457 points benoitg | 59 comments | | HN request time: 1.51s | source | bottom
1. 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 #
2. 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 #
3. hiAndrewQuinn ◴[] No.44365629[source]
I like stuffing everything which might be important to the context window in there, personally. Saving 50ms on the prompt load sure beats a false negative when something goes wrong because I don't even think to ask whether I have the wrong Node version installed or something.
replies(2): >>44365752 #>>44365875 #
4. 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 #
5. bayindirh ◴[] No.44365752{3}[source]
When starting to work on something, I generally do a sanity check to see that the fundamentals are there and correct versions, then throw that part of the context out of mind, knowing that I stand on firm ground.

I found out that with this verify-and-forget step, I work much more efficiently.

As a result, my workflow becomes independent of the machine I work on, because I become the tool, not my setup. After that point, only having a "$" at the beginning of the line is enough.

Of course everyone have their own choices, and YMMV.

6. bredren ◴[] No.44365875{3}[source]
Yes. I show the python or node version of currently active venv and venv name.

Also, I somehow worked in special characters for Python and other things that get screwed up if I don’t have the right nerd font installed on the system.

replies(1): >>44366907 #
7. meesles ◴[] No.44365877[source]
Problem is you can't get timestamps and run times of your commands 'when you really need it', unlike almost everything else
replies(4): >>44365985 #>>44366544 #>>44366632 #>>44367249 #
8. bayindirh ◴[] No.44365985{3}[source]
Why the timestamps are that important? Honestly asking.

You can always time your commands with "time".

replies(2): >>44366033 #>>44366052 #
9. zikduruqe ◴[] No.44366003{3}[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 #
10. stirfish ◴[] No.44366033{4}[source]
I personally use a modified zbell (in zsh) to give me a notification when a command finishes after 30 seconds, and send me an email if it takes over 2 minutes.
replies(1): >>44366109 #
11. bertmuthalaly ◴[] No.44366052{4}[source]
When you’re debugging, especially a complex system, especially during an outage or postmortem, understanding when your commands executed relative to when your log lines appeared is really helpful.
replies(4): >>44366096 #>>44366468 #>>44366844 #>>44368978 #
12. bayindirh ◴[] No.44366096{5}[source]
Oh, that's an interesting use case, alright.
13. bayindirh ◴[] No.44366109{5}[source]
I generally use Konsole's "notify when program exits" feature. For longer tasks, I have a small tool which I pipe to, and it sends me push notification with the output (if I prefer).
replies(1): >>44367373 #
14. acedTrex ◴[] No.44366174{4}[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.
15. styluss ◴[] No.44366468{5}[source]
sounds like your describing https://linux.die.net/man/1/ts
16. alganet ◴[] No.44366505{3}[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 #
17. horsawlarway ◴[] No.44366544{3}[source]
For a personal workstation - you should never "really need it".

It's a personal machine and should be treated as disposable. Doing anything less is fairly irresponsible.

So sure - turn on timestamps for your ssh bastion (although it should be in the logs already...), or turn them on for the ci/cd pipeline (not that you should need them there anyways, since it should be dumping tons of timing info already).

But a personal machine? Plain ol' ">" is plenty.

Not that there's anything wrong with a maximal prompt either... I've definitely done the "configure all the powerline settings!" thing. But I also don't mind a simple ">" or "#".

18. horsawlarway ◴[] No.44366597{4}[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.

19. ericmay ◴[] No.44366603{4}[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 #
20. ljm ◴[] No.44366612[source]
I never bothered configuring my prompt at all because, inside emacs, I could already see most of what I needed in the editor itself.

In fact, I only set up Starship when I started to do more pairing. It wasn’t for my benefit as much as it was for those watching my screen and checking the work, especially when operating on prod and confirming what we wanted to run. I just load up a separate terminal app for that so I don’t have to walk people through my setup.

21. hiAndrewQuinn ◴[] No.44366632{3}[source]
Well, that's why you build it into the prompt. So you don't give yourself the opportunity to forget.
22. acedTrex ◴[] No.44366634{4}[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 #
23. msgodel ◴[] No.44366718{3}[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.
24. kccqzy ◴[] No.44366786{3}[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 #
25. kccqzy ◴[] No.44366844{5}[source]
That's a poor and hacky substitute of using Linux audit features. It's perhaps the right robustness/complexity trade off for my personal machine, but for work they likely already have audit features turned on and you can access the timing from there.
replies(1): >>44367163 #
26. alganet ◴[] No.44366901{5}[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

27. JimDabell ◴[] No.44366907{4}[source]
How often are you switching these things that you need their values in sight at all times though?

Even for cases where I need to use old versions, I don’t need a reminder of that every time I run a command.

replies(1): >>44369787 #
28. fkyoureadthedoc ◴[] No.44366924{4}[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 #
29. andrewflnr ◴[] No.44367092[source]
The exit code of the last command is useful for similar reasons.
30. hiAndrewQuinn ◴[] No.44367163{6}[source]
I think you need to put a number on "likely", here. 80% of all workplaces, maybe? Even that seems a little high. There are a surprising number of devs who have never even heard of auditd. It's just not the kind of thing most people come across in their day to day work unless they go digging for it, or come from a security or DevOps background or something.
31. mechanicum ◴[] No.44367249{3}[source]
As an alternative, perennial HN recommendation atuin (https://atuin.sh) logs time, duration and exit code (among other data) for every command.

That way you only have to look at it when you need it, and you can also figure out what you were doing last week/month/year if necessary.

replies(1): >>44373066 #
32. slightwinder ◴[] No.44367266{4}[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 #
33. stirfish ◴[] No.44367373{6}[source]
I had a tool I'd pipe to, but I'd often only think about it after I'd realize that the command was going to take a while. A push notification sound cool; I used email because I knew how to hack it together with curl.

Here's one zbell implementation, not sure it's the original but it looks like it does the trick: https://gist.github.com/oknowton/8346801

replies(1): >>44387404 #
34. jt_b ◴[] No.44367475{3}[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.
35. freeopinion ◴[] No.44368214{3}[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.
36. MyOutfitIsVague ◴[] No.44368319[source]
nushell does that out of the box:

    > history | get 82076
    ╭─────────────────┬──────────────────╮
    │ start_timestamp │ 2025-06-24 16:46 │
    │ command         │ mpc play         │
    │ cwd             │ /home/work       │
    │ duration        │ 1ms              │
    │ exit_status     │ 0                │
    ╰─────────────────┴──────────────────╯
It's really nice, because it doesn't just tell you time between command executions (or rather time between commands finishing), but the actual runtime duration of the command.
replies(1): >>44374149 #
37. gumbojuice ◴[] No.44368605{5}[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 #
38. skydhash ◴[] No.44368680{3}[source]
Manual git status is enough for me.
39. jonhohle ◴[] No.44368835{5}[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.
40. gcarvalho ◴[] No.44368918{5}[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.

41. xorcist ◴[] No.44368978{5}[source]
That's a good reason to have timestamps in the history, which you should.

Something like

  export HISTFILESIZE=
  export HISTSIZE=
  export HISTTIMEFORMAT="[%F %T] "
  shopt -s histappend
really ought to be default in bash.

It's not as clear why you need it in the interactive prompt.

replies(1): >>44370082 #
42. layer8 ◴[] No.44369209[source]
You could probably (I haven’t tested it) append the run time as a comment to the history using something like PROMPT_COMMAND and `history -r <(…)`, instead of cluttering the prompt with it. And the start time is already in the history, using HISTTIMEFORMAT.
replies(2): >>44370044 #>>44371860 #
43. bredren ◴[] No.44369787{5}[source]
All of the time. Often I'm working with 3-4 different project contexts simultaneously.

It isn't that useful but I do glance it when I'm working on dependencies and to ensure the context between a terminal session and pycharm's interpreter match.

The information doesn't cloud the prompt for me though, as it is right justified and I don't really think about time to load, as the machines are relatively recent Apple Silicon.

44. nine_k ◴[] No.44369984[source]
Current time in a more human-readable format is very helpful sometimes. Also, the exit status of the previous command, if nonzero, is also very helpful when anything fails.
45. hiAndrewQuinn ◴[] No.44370044[source]
Per the Bash `history` manpage:

    int history_write_timestamps
       If non-zero, timestamps are written to the history file, so they can be preserved between sessions.  The default value is 0, [...]
So this isn't true by default on many machines unless it is explicitly turned on. Once you do have it on, of course, then I agree.
replies(1): >>44370519 #
46. hiAndrewQuinn ◴[] No.44370082{6}[source]
I didn't make it quite as clear as I should: the reason to have it in the prompt is mostly so that you, or someone you're working with, can spot a trend you may not consciously think to look for if the timestamps weren't in front of you.

It sounds silly, but it has saved my butt more than once. Especially if you have bugs that e.g. only show up once per hour on the hour, and are otherwise fine.

47. layer8 ◴[] No.44370519{3}[source]
That’s why I wrote “using HISTTIMEFORMAT”, which turns it on. It’s reasonably common to do that.
48. bedlamite ◴[] No.44371860[source]
This is why I really appreciate tools like Atuin. It augments your history with extra data such as the working directory, exit code, time to run command.
49. 1vuio0pswjnm7 ◴[] No.44371893{4}[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
50. magarnicle ◴[] No.44373066{4}[source]
After mucking around for an hour trying to get this information into my prompt, I realised atuin already had it.
51. __MatrixMan__ ◴[] No.44374149[source]
I love nushell. You can also query by friendlier things than index:

     history | where exit_status == 127 | last | get duration
    2sec 410ms
The syntax ends up very clean looking since the data going through the pipes is typed, and the error messages are top notch

      × Types 'duration' and 'int' are not compatible for the '-' operator.
       ╭─[entry #47:1:2]
     1 │ (history | where exit_status == 127 | last | get duration) - 10
       ·  ───┬───                                                   ┬ ─┬
       ·     │                                                      │  ╰── int
       ·     │                                                      ╰── does not operate between 'duration' and 'int'
       ·     ╰── duration
       ╰────
(fingers crossed hn doesn't mangle that...)
52. setopt ◴[] No.44374337{3}[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.

53. 0points ◴[] No.44375513{5}[source]
"git status" is all you need then.
replies(1): >>44377822 #
54. Bagged2347 ◴[] No.44376371{6}[source]
I like this. What do you use to accomplish this?
replies(1): >>44384439 #
55. acedTrex ◴[] No.44377822{6}[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
56. phatskat ◴[] No.44384439{7}[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.

57. bayindirh ◴[] No.44387404{7}[source]
Thanks for sharing the bell. I'll take a look. If you want to try push notifications, I use https://pushover.net as a service.

I developed the tool myself, and it's at https://git.sr.ht/~bayindirh/nudge if you feel like checking it out.

If you want to host the whole push notification infrastructure, you can look at https://ntfy.sh which also can be integrated with cURL.

replies(1): >>44387728 #
58. stirfish ◴[] No.44387728{8}[source]
This is incredibly helpful, thank you. I had no idea push notifications was something I could self-host.
replies(1): >>44387832 #
59. bayindirh ◴[] No.44387832{9}[source]
You're absolutely welcome. Me neither. If I could find ntfy.sh earlier, I'd have written nudge for it, not for Pushover.