4 ms·
The classic copy-pasteable prompt (for true graybeards) is simply PS1='; ' If you want some more information, the trick is this: PS1=': stuff
by enriquto 6y ago
The classic copy-pasteable prompt (for true graybeards) is simply
PS1='; '
If you want some more information, the trick is this:
PS1=': stuff ; '
where "stuff" is whatever string you want to show (without redirection characters). This works because the colon is the "true" executable that ignores all its arguments, and the semicolon introduces your command that can thus be pasted along the whole line.
- stonesweep 6y agoSubtle greybeard update: ` :>/some/file ` still evaluates in shell, it will zero out a file (truncate) quick and dirty - the emphasis in enriquto's comment is still very important, do not include redirection chars.
- diffuse_l 6y agoYou don't even need the ':'. '>/some/file' works as well.
- erlkonig 6y agoThe ";" prompt was specific the "es" and "rc" shells, and not really used with any other more common ones, so most graybeards wouldn't have used that as PS1. Also, to be a graybeard and have copy/paste, you're talking about a very expensive computer with a mouse, like a Sun workstation. And all of those csh users from the late 1980s couldn't have, since it would cause a syntax error :-)
- gumby 6y agoI don't have a beard but I did use c shell from about 1980-1988 when I realized I was an idiot.
- afesfsfresfr 6y agoI remember independently inventing the ": foo;" prompt, and using it with Bash, in the late 90s. My beard is gray now. It's not really practical because there are all sorts of values of "foo" which will make Bash choke when it tries to evaluate the string. Backticks and parentheses, for example, will cause problems, as will newlines (which NB may even occur in filenames, along with other problematic characters!). So the "foo" string typically needs to be sanitized using an external command: https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x279.html https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x279.html Once you get to that point the idea no longer seems as elegant.
- mst 6y agoI just use hostname=; which seems to work out fine. I don't think this trick is really intended for people who want fancy prompts, but I'm not one of them, so it's great for me :)
- atrn 6y agoNo beard but it would be grey... A variant of this has been my PS1 since the 90s (yes, mostly on workstations with a GUI by then [Sun,NeXT,HPUX etc...]). Unfortunately bash doesn't like a lone ';' without something before it ("-bash: syntax error near unexpected token `;'") so I've had to use ':; ' with it (I like its use of readline, emacs user since Gosling's in the early 80s). Triple-click, middle-click (for xterm and others that do that) is efficient and easy. The csh-inspired '!!' can work nicely too though.