this post was submitted on 09 Nov 2023
27 points (96.6% liked)
Linux
47997 readers
919 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Im glad I was able to help!
Something that should be noted when adding colors to your shell prompt function is adding the non printable characters that keep the terminal from buggin out, this caused me a massive headache until I figured it out. When putting it in the PS1 variable directly you will put
\[
to begin a color sequence and\]
to end one, but printf will print a literal[
and]
so instead you will have to use\001
to start and\002
to end, I also recommend changing\e
to\033
or\x1B
to make things a bit more portable. For a quick example\[\e[1;31m\]
would become\001\033[1;31m\002
. Without these characters the terminal will like glitch out when you type a long command and then go back to the front.If you are like messing around or trying to learn a new programming language, you can try like porting your shell prompt to that language, Ive ported mine to C and set it using the same subsitution shell method, I thought it was a fun lil challenge.
But anyways, I hope you have fun customizing your shell prompt!
Thanks, of course the color escapes are the first thing I ran into yesterday, when I played around with prompt functions. ;-)
Porting your prompt command to another language is a very nice and practical little project, perhaps I will give it a go with Go. (Pun intended ;-))
Have a great week!