• bash prompt question

    From =?UTF-8?Q?Fran=C3=A7ois_Patte?=@21:1/5 to All on Thu Sep 19 12:34:55 2024
    Bonjour,

    Wanting to personalize my bash prompt I wrote in my .bashrc file (with
    the help of "Learning the BASH shell"):

    export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[m]\]\$ '

    What I wanted by this :
    specific color
    user@host
    the date
    wether I am on a local machine: nothing or on a remote one: ssh
    and the directory

    It works but not very well: if I use the up/down arrows to call back a
    previous command, the behaviour changes, sometimes as if I used the keys "Inser" or "Suppr" and at the end the usage becomes awfull.

    What did I do wrong?

    I hope to be understable in English language....

    Thank you for helping.

    François Patte

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Elvidge@21:1/5 to All on Thu Sep 19 12:20:40 2024
    On 19/09/2024 at 11:34, François Patte wrote:
    Bonjour,

    Wanting to personalize my bash prompt I wrote in my .bashrc file (with
    the help of "Learning the BASH shell"):

    export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[m]\]\$ '

    try export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[00m\]\$ '

    where do you set $text?


    What I wanted by this :
    specific color
    user@host
    the date
    wether I am on a local machine: nothing or on a remote one: ssh
    and the directory

    It works but not very well: if I use the up/down arrows to call back a previous command, the behaviour changes, sometimes as if I used the keys "Inser" or "Suppr" and at the end the usage becomes awfull.

    What did I do wrong?

    I hope to be understable in English language....

    Thank you for helping.

    François Patte



    --
    Chris Elvidge, England
    I WILL NOT SELL MY KIDNEY ON eBAY

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Fran=C3=A7ois_Patte?=@21:1/5 to All on Thu Sep 19 14:30:19 2024
    Le 19/09/2024 à 13:20, Chris Elvidge a écrit :
    On 19/09/2024 at 11:34, François Patte wrote:
    Bonjour,

    Wanting to personalize my bash prompt I wrote in my .bashrc file (with
    the help of "Learning the BASH shell"):

      export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[m]\]\$ '

    try export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[00m\]\$ '

    I will try this. Thank you.


    where do you set $text?

    I don't know! That's strange... I did this a long time ago and I can't
    remember where I picked up this.

    Doing "echo $text" on a local machine, this returns nothing and on a
    remote one, I get ssh (of course, I am logged to the remote machine,
    using ssh)

    Thank you for helping

    F.P.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gilmeh Serda@21:1/5 to All on Thu Sep 19 18:28:05 2024
    On Thu, 19 Sep 2024 12:34:55 +0200, François Patte wrote:

    Wanting to personalize my bash prompt I wrote in my .bashrc file (with
    the help of "Learning the BASH shell"):

    You could try something like this:
    https://bash-prompt-generator.org/

    Might or might not work for your needs.

    I'm sure there must be similar projects out there.

    --
    Gilmeh

    What's a cult? It just means not enough people to make a minority. --
    Robert Altman

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brian Patrie@21:1/5 to Chris Elvidge on Mon Sep 23 03:07:07 2024
    Chris Elvidge wrote:
    try export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[00m\]\$ '

    In bash (and most shells), PS1, etc do not need to be exported; as long
    as they're set in .bashrc, they will be set in every interactive bash
    session. Moreover, exporting them will make a mess in sh:

    $ export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[00m\]\$ '
    foh@enceladus -Mon Sep 23- ~$ sh
    \[\e[1;35m\]\u@\h -\d- \W\[\e[00m\]$

    sh (and its clones)--which don't support an rc file--are, of course, the exception to this rule.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geoff Clare@21:1/5 to Brian Patrie on Mon Sep 23 13:44:09 2024
    Brian Patrie wrote:

    sh (and its clones)--which don't support an rc file--are, of course, the exception to this rule.

    You don't count a file specified in ENV as an "rc file" ?

    --
    Geoff Clare <netnews@gclare.org.uk>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brian Patrie@21:1/5 to Geoff Clare on Tue Sep 24 01:42:47 2024
    Geoff Clare wrote:
    Brian Patrie wrote:
    sh (and its clones)--which don't support an rc file--are,
    of course, the exception to this rule.

    You don't count a file specified in ENV as an "rc file" ?

    Not all shells support ENV. dash doesn't seem to. Even if they did, it
    would still be a bad idea to export the prompt strings in other shells.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Damien Wyart@21:1/5 to All on Tue Sep 24 10:06:51 2024
    * François Patte <francois.patte@mi.parisdescartes.fr> in comp.unix.shell:
    Wanting to personalize my bash prompt I wrote in my .bashrc file (with
    the help of "Learning the BASH shell"):

    export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[m]\]\$ '

    While it is useful to play with PS1 for learning purposes, to be able to customize
    your prompt easily and in a powerful way, I advise the use of a framework prompt.
    There are many of them, one I really like is Starship:

    https://starship.rs/
    https://github.com/starship/starship

    --
    DW

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to damien.wyart@free.fr on Tue Sep 24 08:51:46 2024
    In article <66f2731d$0$3674$426a34cc@news.free.fr>,
    Damien Wyart <damien.wyart@free.fr> wrote:
    ...
    your prompt easily and in a powerful way, I advise the use of a framework prompt.

    What is a "framework prompt" ?

    --
    Christianity is not a religion.

    - Rick C Hodgin -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Damien Wyart@21:1/5 to All on Tue Sep 24 12:10:13 2024
    * gazelle@shell.xmission.com (Kenny McCormack) in comp.unix.shell:
    What is a "framework prompt" ?

    Sorry, wanted to write "(shell, not LLM) prompt framework" :)

    In addition to Starship, the main ones that come to mind are:
    - https://github.com/liquidprompt/liquidprompt
    - https://github.com/JanDeDobbeleer/oh-my-posh
    - https://github.com/b-ryan/powerline-shell (not active any more, it seems)
    - https://github.com/justjanne/powerline-go

    These two are also very well-known, but only work with zsh:
    - https://github.com/ohmyzsh/ohmyzsh (much wider scope than prompt, but
    customizing it is one the most visible features)
    - https://github.com/sindresorhus/pure

    I use zsh, so I tested most of them and I chose Starship as my daily driver.

    --
    DW

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Damien Wyart on Tue Sep 24 14:11:29 2024
    On 24.09.2024 12:10, Damien Wyart wrote:
    * gazelle@shell.xmission.com (Kenny McCormack) in comp.unix.shell:
    What is a "framework prompt" ?

    Sorry, wanted to write "(shell, not LLM) prompt framework" :)

    Fine. But what is a "framework prompt" (or a "(shell, not LLM)
    prompt framework" if you prefer that)? Since you're suggesting
    something (in context of something as simple as a shell prompt)
    that is obviously not commonly known, do you mind to explain?
    Preferably with a rationale or statement why it shall be used
    (as opposed to just defining prompt the usual and simple way).

    Janis, curious

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Axel Reichert@21:1/5 to Damien Wyart on Tue Sep 24 14:00:18 2024
    Damien Wyart <damien.wyart@free.fr> writes:

    * gazelle@shell.xmission.com (Kenny McCormack) in comp.unix.shell:
    What is a "framework prompt" ?

    Sorry, wanted to write "(shell, not LLM) prompt framework" :)

    In addition to Starship, the main ones that come to mind are:
    - https://github.com/liquidprompt/liquidprompt
    - https://github.com/JanDeDobbeleer/oh-my-posh
    - https://github.com/b-ryan/powerline-shell (not active any more, it seems) - https://github.com/justjanne/powerline-go

    Thanks for the links. I had a quick glance at Starship and found that it
    needs to be installed (in contrast to the prompt generator website
    mentioned else-thread) and seems to have its own configuration language
    (which needs to be learned).

    From my home user's point of view this feels like a whole lot of effort
    for something that at least for me is something that I configure once
    and then do not touch it for years (likewise I do not do shell-hopping).

    Could you please elaborate on your use cases and why you think the IMHO considerable overhead is worthwhile for you?

    Best regards

    Axel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to damien.wyart@free.fr on Tue Sep 24 12:02:14 2024
    In article <66f29006$0$3283$426a74cc@news.free.fr>,
    Damien Wyart <damien.wyart@free.fr> wrote:
    ...
    Sorry, wanted to write "(shell, not LLM) prompt framework" :)

    What is a "(shell, not LLM) prompt framework" ?

    --
    Modern Conservative: Someone who can take time out from demanding more
    flag burning laws, more abortion laws, more drug laws, more obscenity
    laws, and more police authority to make warrantless arrests to remind
    us that we need to "get the government off our backs".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geoff Clare@21:1/5 to Brian Patrie on Tue Sep 24 13:26:01 2024
    Brian Patrie wrote:

    Geoff Clare wrote:
    Brian Patrie wrote:
    sh (and its clones)--which don't support an rc file--are,
    of course, the exception to this rule.

    You don't count a file specified in ENV as an "rc file" ?

    Not all shells support ENV. dash doesn't seem to.

    The dash man page on my Debian system says ENV is supported.

    Even if they did, it would still be a bad idea to export the prompt
    strings in other shells.

    Depends what you put in them. Personally I only use what POSIX
    requires to be supported, so exporting is not a problem (and I do
    export PS1).

    --
    Geoff Clare <netnews@gclare.org.uk>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Damien Wyart on Tue Sep 24 17:47:15 2024
    On 2024-09-24, Damien Wyart <damien.wyart@free.fr> wrote:
    * François Patte <francois.patte@mi.parisdescartes.fr> in comp.unix.shell:
    Wanting to personalize my bash prompt I wrote in my .bashrc file (with
    the help of "Learning the BASH shell"):

    export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[m]\]\$ '

    While it is useful to play with PS1 for learning purposes, to be able to customize
    your prompt easily and in a powerful way, I advise the use of a framework prompt.
    There are many of them, one I really like is Starship:

    https://starship.rs/
    https://github.com/starship/starship

    Or you can put some info into a scroll-protected status line and just
    have $ as your prompt, via a tiny file you just source from your
    .bashrc:

    https://www.kylheku.com/cgit/basta/about/

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Damien Wyart on Tue Sep 24 18:04:44 2024
    On 2024-09-24, Damien Wyart <damien.wyart@free.fr> wrote:
    * François Patte <francois.patte@mi.parisdescartes.fr> in comp.unix.shell:
    Wanting to personalize my bash prompt I wrote in my .bashrc file (with
    the help of "Learning the BASH shell"):

    export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[m]\]\$ '

    While it is useful to play with PS1 for learning purposes, to be able to customize
    your prompt easily and in a powerful way, I advise the use of a framework prompt.
    There are many of them, one I really like is Starship:

    https://starship.rs/
    https://github.com/starship/starship

    This is fucking retarded. It consists of dozens of Rust source files,
    not to mention .json, .yaml and other cruft.

    ... for customizing shell prompts?

    Please tell me it's an April Fool's joke!

    You must not be old enough to remember simple computing with low
    dependencies, and are probably grateful that you don't need a cloud
    account and API key to use this. Or, wait, don't tell me ...

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to 643-408-1753@kylheku.com on Tue Sep 24 18:50:55 2024
    In article <20240924104900.445@kylheku.com>,
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    ...
    This is fucking retarded. It consists of dozens of Rust source files,
    not to mention .json, .yaml and other cruft.

    Yeah, that was the sense I was getting of it.

    It looked to me like he was just trying to get people to click on his
    links. Still, we must remain charitable. Sometimes, this is the only
    path available for some folks to get out of their third world shithole.

    ... for customizing shell prompts?

    Please tell me it's an April Fool's joke!

    More likely, just clickbait.

    You must not be old enough to remember simple computing with low >dependencies, and are probably grateful that you don't need a cloud
    account and API key to use this. Or, wait, don't tell me ...

    Probably so.

    --
    A Catholic woman tells her husband to buy Viagra.

    A Jewish woman tells her husband to buy Pfizer.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Damien Wyart@21:1/5 to All on Wed Sep 25 08:02:57 2024
    * Kaz Kylheku <643-408-1753@kylheku.com> in comp.unix.shell:
    You must not be old enough to remember simple computing with low
    dependencies

    I have been using Unixes daily since 1996.

    --
    DW

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Damien Wyart@21:1/5 to All on Wed Sep 25 10:53:20 2024
    I have some NNTP issues (I can see much more articles on the public read-only server I use than on the other one I use to post) ; I almost never post nowadays
    and Usenet is really extremely niche now, so I do not want to invest time on fixing...

    I will still answer very quickly to this even if I vaguely feel a trollish tone:

    Fine. But what is a "framework prompt" (or a "(shell, not LLM)
    prompt framework" if you prefer that)? Since you're suggesting
    something (in context of something as simple as a shell prompt)
    that is obviously not commonly known, do you mind to explain?
    Preferably with a rationale or statement why it shall be used
    (as opposed to just defining prompt the usual and simple way).

    I'm not interested in bike-shedding on words, we can call them prompt tools or whatever, I don't care.

    "not commonly known" might be true in this newsgroup, but if we look at the "Github stars" for all the projects I quoted (yes, I know, this metric is not perfect and can be criticized), they sum up to about 235000, so these projects clearly have users.

    If you have a quick look at the tools (why would the whole "evidence" be on my side?), what they have in common is:
    - they provide much more pieces of info you can choose to display (see right
    column on https://starship.rs/config/) and, importantly, to not display if they
    are not relevant to you
    - this info is dynamic and comes from many sources unknown from the shell itself
    - they are contextual: the display depends on the current directory and its
    content
    - they can be configured in much details and you do not need to fiddle with ANSI
    codes to add colors, for example.


    I will stop here on this whole topic, if people hate external prompt tools, they
    are free to not use them.

    --
    DW

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Damien Wyart@21:1/5 to All on Wed Sep 25 10:33:50 2024
    These two are also very well-known, but only work with zsh:
    - https://github.com/ohmyzsh/ohmyzsh (much wider scope than prompt, but
    customizing it is one the most visible features)
    - https://github.com/sindresorhus/pure

    Just for the reference and to be more complete, I will add this one to the list:
    https://github.com/spaceship-prompt/spaceship-prompt

    also quite well known and which inspired Starship which was initially a rewrite in
    a compiled langage to make execution much faster.

    --
    DW

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Damien Wyart on Wed Sep 25 19:28:40 2024
    On 25.09.2024 10:53, Damien Wyart wrote:
    I have some NNTP issues (I can see much more articles on the public read-only server I use than on the other one I use to post) ; I almost never post nowadays
    and Usenet is really extremely niche now, so I do not want to invest time on fixing...

    I will still answer very quickly to this even if I vaguely feel a trollish tone:

    Fine. But what is a "framework prompt" (or a "(shell, not LLM)
    prompt framework" if you prefer that)? Since you're suggesting
    something (in context of something as simple as a shell prompt)
    that is obviously not commonly known, do you mind to explain?
    Preferably with a rationale or statement why it shall be used
    (as opposed to just defining prompt the usual and simple way).

    I'm not interested in bike-shedding on words, we can call them prompt tools or
    whatever, I don't care.

    "not commonly known" might be true in this newsgroup, but if we look at the "Github stars" for all the projects I quoted (yes, I know, this metric is not perfect and can be criticized), they sum up to about 235000, so these projects
    clearly have users.

    If you have a quick look at the tools (why would the whole "evidence" be on my
    side?), what they have in common is:
    - they provide much more pieces of info you can choose to display (see right
    column on https://starship.rs/config/) and, importantly, to not display if they
    are not relevant to you
    - this info is dynamic and comes from many sources unknown from the shell itself
    - they are contextual: the display depends on the current directory and its
    content
    - they can be configured in much details and you do not need to fiddle with ANSI
    codes to add colors, for example.


    I will stop here on this whole topic, if people hate external prompt tools, they
    are free to not use them.

    With this belligerent stance (that obviously blurred your perception)
    you seem to have completely missed the intent of the various responses
    to your post, despite they were coherent across the posts and should
    in their own individual ways of expression have been quite clear.

    It was not about finding a fitting word for the software package.
    It was not about click-rate or download statistics of that tool.
    It was not about emotions towards the tool (fans/you vs. haters).

    It was simply about what that package is supposed to do.
    And why it's worth to install and use that huge package.

    From all the posts (yours and other responses) I guess that you have
    to install a (huge) package to introduce a layer between you and your
    shell, that all input and output gets intercepted and transformed in
    ways that can be controlled by an enormously large configuration file.
    [ Such sort of an answer I would have hoped to get from you to shed
    some light on the questions, along with some application examples
    to better understand your decision why you prefer to use the tool.]

    Personally, I generally try to avoid dependencies, especially to such voluminous packages with questionable utility and unknown reliability
    and potential interference to my environment. I prefer using standard environments as much as possible and sensible, to be able to work the
    same way when switching to other environments. Using e.g. ANSI codes
    (if sensible) is no burden for me, certainly not more than learning a
    software package and its extensive configuration options. (YMMV.)

    Janis

    PS: *If* the package is effectively an intercepting layer I wonder
    how it will pass functions that I use in my shell (e.g. Vi Editing
    Mode) to the shell. Note: this is just of academic interest to me,
    so don't bother. But I suspect you're probably anyway not the right
    person here to answer that, so I put it just in the post scriptum.
    But, if I mis-assessed, feel free to enlighten us with some facts.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Damien Wyart@21:1/5 to All on Wed Sep 25 21:41:16 2024
    From all the posts (yours and other responses) I guess that you have to install
    a (huge) package to introduce a layer between you and your shell, that all input
    and output gets intercepted and transformed

    No.

    PS: *If* the package is effectively an intercepting layer I wonder how it will
    pass functions that I use in my shell (e.g. Vi Editing Mode) to the shell.

    I will only answer for Starship (I did not study the other tools deeply) and bash
    (quite "standard"): Starship only relies on PROMPT_COMMAND, PS0, PS1 and PS2, so
    once its prompt displaying is done, the shell is normal and gets its input as usual. Same for the output of commands, it doesn't goes through Starship itself.

    --
    DW

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)