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
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?
Wanting to personalize my bash prompt I wrote in my .bashrc file (with
the help of "Learning the BASH shell"):
try export PS1='\[\e[1;35m\]\u@\h -\d- ${text} \W\[\e[00m\]\$ '
sh (and its clones)--which don't support an rc file--are, of course, the exception to this rule.
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" ?
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]\]\$ '
your prompt easily and in a powerful way, I advise the use of a framework prompt.
What is a "framework prompt" ?
* gazelle@shell.xmission.com (Kenny McCormack) in comp.unix.shell:
What is a "framework prompt" ?
Sorry, wanted to write "(shell, not LLM) prompt framework" :)
* 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
Sorry, wanted to write "(shell, not LLM) prompt framework" :)
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.
* 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
* 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 ...
You must not be old enough to remember simple computing with low
dependencies
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).
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 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.
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
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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 497 |
Nodes: | 16 (2 / 14) |
Uptime: | 28:24:12 |
Calls: | 9,796 |
Calls today: | 15 |
Files: | 13,749 |
Messages: | 6,188,556 |