Live data from Hacker News

Bash PS1 Generator

bashrcgenerator.com

121–130 of 146 posts

Re: Bash PS1 Generator

#121
post #98

Earlier quoted context omitted.

I mean, the other alternative is just keep your prompt simple. ;-)

This. The one time a month when I can't remember which git branch I'm on I'll just run 'git branch'. If you're feeling frisky, you could even alias that to 'gb'.

>you could even alias that to 'gb'.

oh-my-zsh does this by default as it comes with the "git" plugin loaded. "gb -vv" is a common thing I run.

Re: Bash PS1 Generator

#122

Earlier quoted context omitted.

This. The one time a month when I can't remember which git branch I'm on I'll just run 'git branch'. If you're feeling frisky, you could even alias that to 'gb'.

One time a month? Currently I have 85 work related repositories checked out, putting the current git branch and current Kubernetes context in the prompt is helping to avoid mistakes. I also have a newline in my prompt which makes it easier to copy commands and output into Jira.

85 repos seems like so many. Are you making many changes that need to span across multiple? How many are touched over the course of a week?

Re: Bash PS1 Generator

#123
post #104
post #32

Earlier quoted context omitted.

Starship is the only prompt I've used that has (a) sane defaults, (b) cross platform support as well as ease of installation, and (c) good enough speed. Powerline is much slower, and I lose my serenity everytime I have to fiddle with dotfiles.

I just got ~/bin via v1.8.0 via v2.7.16 on (us-east-2) [1] even on non-project folders and have no idea why that is being listed. [1] emojis got lost in hn, but it was a coffee cup, a snake and a cloud..

https://starship.rs/config/#default-prompt-format

Re: Bash PS1 Generator

#124
post #14

Notes: * As an idea, this is excellent. It's intuitive to use and provides full instructions on how to implement * Putting an element in any other position than the end of the prompt is fiddly. * I'd love for the option to to be able to colour elements. * More advanced or exotic element types such as Git Branch would be excellent (Not sure if Bash supports this, but I've seen it in some shells)

There's one prompt in ZSH, the adam2 prompt[1], that I completely fell in love with due to the automatic horizontal rule since it makes tracing histories so much easier when dealing with long-scrolling outputs. I've never been able to find a similar feature in another prompt/shell, nor have I had the inclination to try and replicate it, but I'd be much more inclined to switch shells/try new prompts if that were available.

[1]: https://imgur.com/1X9bY8X

Re: Bash PS1 Generator

#125

Earlier quoted context omitted.

One time a month? Currently I have 85 work related repositories checked out, putting the current git branch and current Kubernetes context in the prompt is helping to avoid mistakes. I also have a newline in my prompt which makes it easier to copy commands and output into Jira.

85 repos seems like so many. Are you making many changes that need to span across multiple? How many are touched over the course of a week?

I'm guessing this place is not using mono-repo. ;-)

Re: Bash PS1 Generator

#126

Seeing '>' as an option makes it somewhat relevant to mention here: I'd recommend not ending your prompt with a '>' character (as you'd see in DOS/Windows a lot, which might make it seem like a nice option). If you accidentally copy and paste your prompt with a command after it, (which is easy to do with a couple mouse clicks, or if you forget what's in your clipboard after copying some lines from your terminal,) the…

I would have never thought of that. ty for the tip

Re: Bash PS1 Generator

#127

Earlier quoted context omitted.

Terminal app feature idea: a hotkey that puts the last command run in the copy buffer

function copy_last_command { history 1 | sed 's/ [0-9]* //' | xclip -i } bind -x '"\C-h":copy_last_command'

The Mac equivalent of xclip -i is pbcopy

Re: Bash PS1 Generator

#128

Seeing '>' as an option makes it somewhat relevant to mention here: I'd recommend not ending your prompt with a '>' character (as you'd see in DOS/Windows a lot, which might make it seem like a nice option). If you accidentally copy and paste your prompt with a command after it, (which is easy to do with a couple mouse clicks, or if you forget what's in your clipboard after copying some lines from your terminal,) the…

I would have never thought of that. ty for the tip

Learned about that when a co-worker did that about 20 years ago.

Re: Bash PS1 Generator

#129
post #33

Here's what I'm currently rocking: 0 0:00:00 ~/Code/company/app$ First number is exit code of previous command, second is how long it took. Credit to https://unix.stackexchange.com/questions/252229/ps1-prompt-t... for the last part. It's a bit ratchet: - I actually don't care about the exit code unless it was non-zero - It calculates the delta three times but I've been to busy to optimise it. prompt_command() { _PS1_…

Here's what I'm currently rolling:

  $
A colorful prompt appears, only when 'user or hostname or path' changes, or after certain commands:

  - username@hostname:pwd
  $
Somewhere in .bash_aliases ...

  ### PROMPT ###

  ### long prompt (in color) only when 'user or hostname or path' changes, or after certain commands
  prompt_command () 
  { 
    local -a a;
    local last_cmd;
    IFS=' ' read -r -d '' -a a 

Re: Bash PS1 Generator

#130
post #36

I think the drag-n-drop UI is less intuitive. Wasted a few minutes trying to click these items as "buttons" and wondering if there's something wrong because of the http-onlyness of the site (console gives a lot of warning).

Shame is not single click, I thought it was broken on mobile because nothing happened when I click, then I knew it doesn't work on mobile when I realised it's drag and drop.
Post reply on HN