Live data from Hacker News

Bash PS1 Generator

bashrcgenerator.com

61–70 of 146 posts

Re: Bash PS1 Generator

#64

Earlier quoted context omitted.

While https is a good default, and LetsEncrypt has made it relatively trivial, I wouldn't say this particularly needs it; there isn't any user data at all. I suppose without TLS it could be intercepted and modified to return a malicious bash command, or something, but this random site on the internet could do that on its own without being intercepted anyway.

> 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.

Re: Bash PS1 Generator

#66

Normally I don't post much about how a site should use HTTPS on HN, but for this specific instance I think it's important.

I agree. If the maintainer is here, you can use certbot to add HTTPS easily on your existing Apache 2/Debian stack. If you're on Stretch or Buster the official instructions are the same: https://certbot.eff.org/lets-encrypt/debianstretch-apache

One note: I hate snaps and don't use them personally, but it would make it very easy for you to add HTTPS without changing your existing stack.

Re: Bash PS1 Generator

#67
post #54

On the site all prompt variables end in "tput sgr0". I haven't seen that before. What does that do and why is it needed?

tput query a terminfo database and return an escape code suitable for that $TERM. sgr0 is the name for "reset" (e.g. "\033[0;10m" in ANSI). Using tput instead of escape code directly is better in a lot of ways. For example, it allows the shell script to be adaptive to the type of TERM it runs on (e.g. not outputting color codes at all if TERM doesn't support colors). You can see what each tput commands are doing by r…

tput uses the terminfo database which is usually located in /usr/share/terminfo.

If your terminal ($TERM) is not known to the operating system, you can also import the terminfo definition from another OS in a directory and point the TERMINFO environment variable to it (useful if the legacy OS you connect to via SSH doesn't have full support for your fancy terminal emulator).

Re: Bash PS1 Generator

#68
post #46

Am I the only one who leaves mine as is?

Well, the default prompt you have may already have been customized by operating system vendor (Linux distro) and not be the real bash default.

Try this to get the real default:

    PS1='[\u@\h \W]\$ '

Re: Bash PS1 Generator

#70

On the site all prompt variables end in "tput sgr0". I haven't seen that before. What does that do and why is it needed?

Others explained why. But, it’s not really been necessary since maybe the early 90s, unless you have hardware terminals around?

It’s more efficient to echo CSI 0m, in shell than to run another process to do the same. Every mainstream terminal supports it.

Post reply on HN