Computer Old Farts Forum
 help / color / mirror / Atom feed
* [COFF] What is your prompt? (was: ksh88 source code?)
@ 2021-12-23  6:59 Andy Kosela
  2021-12-23 12:04 ` John P. Linderman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Kosela @ 2021-12-23  6:59 UTC (permalink / raw)
  To: Adam Thornton; +Cc: Computer Old Farts Followers

On 12/22/21, Adam Thornton <athornton@gmail.com> wrote:
> MacOS finally pushed me to zsh.  So I went all the way and installed
> oh-my-zsh.  It makes me feel very dirty, and I have a two-line prompt (!!),
> but I can't deny it's convenient.
>
> tickets/DM-32983 ✗
> adam@m1-wired:~/git/jenkins-dm-jobs$
>
> (and in my terminal, the X glyph next to my git branch showing the status
> is dirty is red while the branch name is green)
>
> and if something doesn't exit with rc=0...
>
> adam@m1-wired:~/git/jenkins-dm-jobs$ fart
> zsh: command not found: fart
> tickets/DM-32983 ✗127 ⚠️
> adam@m1-wired:~/git/jenkins-dm-jobs$
>
> Then I also get the little warning glyph and the rc of the last command in
> my prompt.
>
> But then I'm also now using Fira Code with ligatures in my terminal, so
> I've pretty much gone full Red Lightsaber.

I try to keep my prompt as simple as possible.  For years I have been using:

  moon $

That 's it.  No fancy colors, not even displaying current working
directory.  I have an alias 'p' for that.

--Andy
_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [COFF] What is your prompt? (was: ksh88 source code?)
  2021-12-23  6:59 [COFF] What is your prompt? (was: ksh88 source code?) Andy Kosela
@ 2021-12-23 12:04 ` John P. Linderman
  2021-12-23 19:30 ` Nemo Nusquam
  2021-12-24 17:17 ` [COFF] What is your prompt? Grant Taylor via COFF
  2 siblings, 0 replies; 5+ messages in thread
From: John P. Linderman @ 2021-12-23 12:04 UTC (permalink / raw)
  To: Andy Kosela; +Cc: Computer Old Farts Followers


[-- Attachment #1.1: Type: text/plain, Size: 2268 bytes --]

I've been a "fancy prompt" fan for decades. It started when I got (possibly
the first) CRT (HP2641?) at Bell Labs with command re-entry capability. I
put a @ at the end of my prompt, so when I re-entered a line, the prompt
itself would disappear (@ was the default line-kill character in the
pre-internet era). As it got possible to make ksh  prompts fancier, I put a
newline at the end of the prompt, and used command number, host name, and
working directory, color coded (although that may well not show up):

1896 jpl:/home/jpl/Downloads

Easy to visually distinguish prompts from commands, and copy/paste
commands. And I jiggered a local cd command to put
  user@host ptty current-directory window-size
in the terminal window title. Handier before I retired, when I had many
hosts I might be visiting with ssh. Overkill, arguably, but CPU cycles are
cheap now.


On Thu, Dec 23, 2021 at 2:00 AM Andy Kosela <akosela@andykosela.com> wrote:

> On 12/22/21, Adam Thornton <athornton@gmail.com> wrote:
> > MacOS finally pushed me to zsh.  So I went all the way and installed
> > oh-my-zsh.  It makes me feel very dirty, and I have a two-line prompt
> (!!),
> > but I can't deny it's convenient.
> >
> > tickets/DM-32983 ✗
> > adam@m1-wired:~/git/jenkins-dm-jobs$
> >
> > (and in my terminal, the X glyph next to my git branch showing the status
> > is dirty is red while the branch name is green)
> >
> > and if something doesn't exit with rc=0...
> >
> > adam@m1-wired:~/git/jenkins-dm-jobs$ fart
> > zsh: command not found: fart
> > tickets/DM-32983 ✗127 ⚠️
> > adam@m1-wired:~/git/jenkins-dm-jobs$
> >
> > Then I also get the little warning glyph and the rc of the last command
> in
> > my prompt.
> >
> > But then I'm also now using Fira Code with ligatures in my terminal, so
> > I've pretty much gone full Red Lightsaber.
>
> I try to keep my prompt as simple as possible.  For years I have been
> using:
>
>   moon $
>
> That 's it.  No fancy colors, not even displaying current working
> directory.  I have an alias 'p' for that.
>
> --Andy
> _______________________________________________
> COFF mailing list
> COFF@minnie.tuhs.org
> https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff
>

[-- Attachment #1.2: Type: text/html, Size: 3404 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [COFF] What is your prompt? (was: ksh88 source code?)
  2021-12-23  6:59 [COFF] What is your prompt? (was: ksh88 source code?) Andy Kosela
  2021-12-23 12:04 ` John P. Linderman
@ 2021-12-23 19:30 ` Nemo Nusquam
  2021-12-24 17:17 ` [COFF] What is your prompt? Grant Taylor via COFF
  2 siblings, 0 replies; 5+ messages in thread
From: Nemo Nusquam @ 2021-12-23 19:30 UTC (permalink / raw)
  To: coff

On 2021-12-23 01:59, Andy Kosela wrote:
> On 12/22/21, Adam Thornton <athornton@gmail.com> wrote (in part):
>> MacOS finally pushed me to zsh.  So I went all the way and installed
>> oh-my-zsh.  It makes me feel very dirty, and I have a two-line prompt (!!),
>> but I can't deny it's convenient.
>>
> I try to keep my prompt as simple as possible.  For years I have been using:
>
>    moon $
>
> That 's it.  No fancy colors, not even displaying current working
> directory.  I have an alias 'p' for that.

export PS1="\! [\W]=> " (mixing various historical references).

N.
_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [COFF] What is your prompt?
  2021-12-23  6:59 [COFF] What is your prompt? (was: ksh88 source code?) Andy Kosela
  2021-12-23 12:04 ` John P. Linderman
  2021-12-23 19:30 ` Nemo Nusquam
@ 2021-12-24 17:17 ` Grant Taylor via COFF
  2021-12-26 22:17   ` Mike Markowski
  2 siblings, 1 reply; 5+ messages in thread
From: Grant Taylor via COFF @ 2021-12-24 17:17 UTC (permalink / raw)
  To: coff


[-- Attachment #1.1: Type: text/plain, Size: 3927 bytes --]

On 12/22/21 11:59 PM, Andy Kosela wrote:
> What is your prompt?
Pre-Script:  Seeing as how this is COFF and it's supposed to be a slow 
day at work (holding down the fort while others celebrate) I'll chime 
in.  What follows is what the type of thing that I'd be interested in 
reading from others.

I've been a *LONG* *TIME* advocate for having at the very minimum 1) the 
(current) username and 2) the hostname in the prompt.  This became 
exceedingly apparent at my last job with a bunch of junior admins, too 
many of which (read: > 0), inadvertently issued commands as the wrong 
user and / or on the wrong host.

I personally like having the current working directory in the prompt.

After some other incidents at my previous job, I started advocating for 
having the leading character in the prompt be a "#" so that most shells 
would not interpret it as a command pasted with trailing carriage return.

This brings me to the quintessential Bash / Zsh PS1 prompt of:

    PS1="#[\u@\h:\w]\$ "

The square brackets are effectively eye candy.  The \$ evaluates to 
indication of if you're running as a normal user or root.  It's largely 
superfluous with \u in the prompt.  But it makes things uniform and 
reduces questions when others are learning things.

When I migrated to Zsh, my prompt got a bit more complex.  The base 
prompt in a new terminal window still looks mostly the same as the above 
PS1.  The biggest difference is that I use Zsh's RPROMPT for transient 
things like the previous commands return code ($?) and date & time (the 
prompt was printed).  The RPROMPT has the nice feature of it leaves the 
screen when when the current command is executed, thus it doesn't 
clutter screen scroll back.

I'm leveraging Zsh's conditional prompt features to make the return code 
($?) stand out in bright white on bright red when $? != 0.

My shell initialization files conditionally set various environment 
variables which are used in the prompt.  Conditionally on things like:

  - the TERM type
  - my terminal emulator's answer back - used for terminal specific features
  - shell level
  - if the shell is forked from inside of screen / tmux
  - if the shell is forked from inside of vim

Depending on the TERM type and my terminal's answer back I'll either 
include control sequences to set the window title to (simplified version 
of) the PS1 prompt.  This way I have a good idea from the window title 
when selecting minimized windows from lists, where the terminal therein is.

I'm leveraging Zsh's preexec() function to conditionally set the window 
title to the command that's being executed if answer back indicates a 
supported terminal emulator.

I'm comparing the host name to the value of answer back to set the 
prompt color as a simple indicator if I'm on my local system or not.

  - Green  = terminal to local system
  - Yellow = terminal to a non-local system
  - Red    = terminal as root window somewhere, BE CAREFUL

So ... my Zsh prompt has a fair bit behind it.  But the bulk of what's 
printed is still the comment character, the username, the hostname, the 
current working directory, and the (non)root indicator.

One deviation is that I now have my root prompt (via sudo / su) slightly 
different in that after the effective user name, root, the prompt also 
includes my real user name in parenthesis.

    #[root(gtaylor)@host:~]#

As I do more with containers, I'm getting ready to implement a similar 
permutation on the host portion such that the host name portion reflects 
the container's / network namespace's value of \h with parent host OS's 
name in side of parenthesis, much like the effective / logged in user pair.

    #[root(gtaylor)@netns(host):~]#

Post-Script:  Happy holidays.  Here's hoping that things are going well 
for you and yours.



-- 
Grant. . . .
unix || die


[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4017 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [COFF] What is your prompt?
  2021-12-24 17:17 ` [COFF] What is your prompt? Grant Taylor via COFF
@ 2021-12-26 22:17   ` Mike Markowski
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Markowski @ 2021-12-26 22:17 UTC (permalink / raw)
  To: coff


[-- Attachment #1.1: Type: text/plain, Size: 182 bytes --]

>
> On 12/22/21 11:59 PM, Andy Kosela wrote:
> What is your prompt?

 I prefer minimalism:  export PS1="\h$ "

Similarly, in ham radio I prefer CW (Morse code).  :-)

Mike Markowski

[-- Attachment #1.2: Type: text/html, Size: 451 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-26 22:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23  6:59 [COFF] What is your prompt? (was: ksh88 source code?) Andy Kosela
2021-12-23 12:04 ` John P. Linderman
2021-12-23 19:30 ` Nemo Nusquam
2021-12-24 17:17 ` [COFF] What is your prompt? Grant Taylor via COFF
2021-12-26 22:17   ` Mike Markowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).