[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
slackbook:bash [2012/09/08 18:05 (UTC)] – [Terminals] updated section to match original with formatting mfillpot | slackbook:bash [2012/09/08 18:10 (UTC)] – [Sources] updated author list mfillpot | ||
---|---|---|---|
Line 342: | Line 342: | ||
===== Customization ===== | ===== Customization ===== | ||
- | By now you should be pretty familiar with bash and you may have even noticed some odd behavior. For example, when you login at the console, you're presented with a prompt that looks a bit like this. | + | By now you should be pretty familiar with |
+ | **//bash//** and you may have even noticed some odd | ||
+ | behavior. For example, when you login at the console, you're presented | ||
+ | with a prompt that looks a bit like this. | ||
< | < | ||
- | alan@darkstar: | + | alan@darkstar: |
- | </ | + | |
However, sometimes you'll see a much less helpful prompt like this one. | However, sometimes you'll see a much less helpful prompt like this one. | ||
+ | |||
< | < | ||
- | bash-3.1$ | + | bash-3.1$ </ |
- | </ | + | |
+ | |||
+ | The cause here is a special environment variable that controls the | ||
+ | **// | ||
+ | //" | ||
+ | different configuration files when started. Login shells read | ||
+ | ''/ | ||
+ | '' | ||
+ | read '' | ||
+ | for power users, but is a common annoyance for many new users who want | ||
+ | the same environment anytime they execute | ||
+ | **// | ||
+ | between login and interactive shells. If this applies to you, simply | ||
+ | edit your own ~/.bashrc file and include the following lines. | ||
+ | (For more information on | ||
+ | the different configuration files used, read the INVOCATION section of | ||
+ | the **// | ||
- | The cause here is a special environment variable that controls the bash prompt. Some shells are considered " | ||
< | < | ||
+ | |||
# ~/.bashrc | # ~/.bashrc | ||
. / | . / | ||
Line 361: | Line 383: | ||
</ | </ | ||
- | When using the above, all your login and interactive shells will have the same environment settings and behave identically. Now, anytime we wish to customize a shell setting, we only have to edit ~/ | ||
- | bash prompts come in all shapes, colors, and sizes, and every user has their own preferances. Personally, I prefer short and simple prompts that take up a minimum of space, but I've seen and used mutli-line prompts many times. One personal friend of mine even included ASCII-art in his bash prompt. To change your prompt you need only to change your PS1 variable. By default, Slackware attempts to configure your PS1 variable thusly: | + | When using the above, all your login and interactive shells will have |
+ | the same environment settings and behave identically. Now, anytime we | ||
+ | wish to customize a shell setting, we only have to edit | ||
+ | '' | ||
+ | ''/ | ||
+ | configuring the prompt. | ||
+ | |||
+ | |||
+ | **//bash//** prompts come in all shapes, colors, and | ||
+ | sizes, and every user has their own preferances. Personally, I prefer | ||
+ | short and simple prompts that take up a minimum of space, but I've seen | ||
+ | and used mutli-line prompts many times. One personal friend of mine | ||
+ | even included ASCII-art in his bash prompt. To change your prompt you | ||
+ | need only to change your PS1 variable. By default, Slackware attempts | ||
+ | to configure your PS1 variable thusly: | ||
< | < | ||
darkstar:~$ echo $PS1 | darkstar:~$ echo $PS1 | ||
- | \u@\h: | + | \u@\h:\w\$ </ |
- | </ | + | |
- | Yes, this tiny piece of funny-looking figures controls your bash prompt. Basicaly, every character in the PS1 variable is included in the prompt, unless it is a escaped by a \, which tells bash to interpret it. There are many different escape sequences and we can't discuss them all, but I'll explain these. The first " | ||
- | Since we've gone through all this trouble to discuss the default prompt, I thought I'd take some time to show you a couple example prompts and the PS1 variable values needed to use them. | + | Yes, this tiny piece of funny-looking figures controls your |
+ | **// | ||
+ | the PS1 variable is included in the prompt, unless it is a escaped by a | ||
+ | < | ||
+ | interpret it. There are many different escape sequences and we can' | ||
+ | discuss them all, but I'll explain these. | ||
+ | the username of the current user. //" | ||
+ | the terminal is attached to. //" | ||
+ | //" | ||
+ | depending on whether or not the current user is root. A complete | ||
+ | listing of all prompt escape sequences is listed in the | ||
+ | **// | ||
+ | |||
+ | |||
+ | Since we've gone through all this trouble to discuss the default | ||
+ | prompt, I thought I'd take some time to show you a couple example | ||
+ | prompts and the PS1 variable values needed to use them. | ||
< | < | ||
Line 383: | Line 434: | ||
</ | </ | ||
- | For even more information on configuring your bash prompt, including information on setting up colored prompts, refer to / | ||
+ | For even more information on configuring your bash prompt, including | ||
+ | information on setting up colored prompts, refer to | ||
+ | ''/ | ||
+ | reading that for a short while, you'll get an idea of just how powerful | ||
+ | your **// | ||
+ | prompt that gave me up to date weather information such as temperature | ||
+ | and barometric pressure! | ||
+ | |||
+ | ====== Chapter Navigation ====== | ||
+ | |||
+ | **Previous Chapter: [[slackbook: | ||
+ | |||
+ | **Next Chapter: [[slackbook: | ||
====== Sources ====== | ====== Sources ====== | ||
<!-- If you copy information from another source, then specify that source --> | <!-- If you copy information from another source, then specify that source --> | ||
- | * Original source: [[http:// | + | * Original source: [[http:// |
<!-- Authors are allowed to give credit to themselves! --> | <!-- Authors are allowed to give credit to themselves! --> | ||
- | < | + | * Originally written by Alan Hicks, Chris Lumens, David Cantrell, Logan Johnson |
<!-- * Contrbutions by [[wiki: | <!-- * Contrbutions by [[wiki: | ||