Live data from Hacker News

Bash PS1 Generator

bashrcgenerator.com

91–100 of 146 posts

Re: Bash PS1 Generator

#91
I don’t see a ‘#’ option there. It’s a valuable command line inclusion to keep copypasta from executing something you may not intend. Also, the ability to check what branch I’m in (assuming cwd is in a git repo) is a useful prompt inclusion.

Re: Bash PS1 Generator

#92
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 first thing after the > sign is the file for a script or executable and you will truncate the file (make it 0 bytes). This can be especially bad if you're root at the time. (That makes # as a root prompt especially a good idea.)

Re: Bash PS1 Generator

#93

current git branch is missing (helps me to avoid working on the wrong branch). (tried to do it with colors, but things got too messy). I never managed to work with colors in bash propmts; they look different on each environment. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } PS1="[\u@\h \W\$(parse_git_branch)]\$ "

Nowadays there's the `--show-current` option:

    git branch --show-current
See https://git-scm.com/docs/git-branch

Re: Bash PS1 Generator

#95
I think there's a bug, at least in Firefox. When you drag to remove an element from the currently active set, the "sample output" only updates after making _another_ change. So if you drag to remove two elements one-at-a-time, the "sample output" will lag one action behind what you have in the workspace.

Re: Bash PS1 Generator

#96

Earlier quoted context omitted.

> I wouldn't say this particularly needs it; there isn't any user data at all. I use NoScript. This page requires me to enable JavaScript for it to work. Because it doesn't use TLS, this allows any miscreant in the middle to injected JS doing god-knows-what into my browser. If you really insist (in this case IMO understandable) on having me download and run your program, written in a turing complete scripting languag…

But no one is insisting.

"It must turn on the JavaScript, or it gets the blank page again" - The Silence of the LAMPs

--

https://en.wiktionary.org/wiki/insist#Verb

Wiktionary is a website that has improved functionality after turning on JavaScript, but works just fine without it. It does not insist on using JavaScript.

I guess what you actually mean is "no one is insisting on me looking at their website"? That would be true, but I don't recall making any contrary claims.

If I do want to look at a website, the site insists on using JavaScript, but does not use HTTPS, that can be a security issue. That's what my original comment tries to point out.

Re: Bash PS1 Generator

#97

Use https://starship.rs/ abs get the same prompt in all your shells. Also it’s written in rust, so it’s faster than a load of bash scripts.

Absolutely a quality of life tool. Very few excuses left to put up with zsh + Oh-My-Zash.

Re: Bash PS1 Generator

#98
post #97

Use https://starship.rs/ abs get the same prompt in all your shells. Also it’s written in rust, so it’s faster than a load of bash scripts.

Absolutely a quality of life tool. Very few excuses left to put up with zsh + Oh-My-Zash.

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

Re: Bash PS1 Generator

#99

current git branch is missing (helps me to avoid working on the wrong branch). (tried to do it with colors, but things got too messy). I never managed to work with colors in bash propmts; they look different on each environment. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } PS1="[\u@\h \W\$(parse_git_branch)]\$ "

This is the PS1 I've been using for a long time:

export PS1="\n\$(kube_ps1)\n\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[0;31m\]\$(__git_ps1)\n\$\[\033[00m\] "

Note it needs the git-prompt.sh script (usually comes with the bash-completion package), and the kube-ps1 script: https://github.com/jonmosco/kube-ps1

It will show you the current kubernetes profile and namespace, user@host, current directory and git branch if you're in a git repo.

Post reply on HN