https://wiki.archlinux.org/api.php?action=feedcontributions&user=JuszR&feedformat=atomArchWiki - User contributions [en]2024-03-29T00:11:59ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Bash/Prompt_customization&diff=250512Bash/Prompt customization2013-03-13T14:52:50Z<p>JuszR: /* /etc/bash.bashrc */</p>
<hr />
<div>[[Category:Eye candy]]<br />
[[Category:Command shells]]<br />
[[es:Color Bash Prompt]]<br />
[[it:Color Bash Prompt]]<br />
[[ru:Color Bash Prompt]]<br />
{{Article summary start}}<br />
{{Article summary text|Discussing and improving Bash graphical customisations.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Environment Variables}}<br />
{{Article summary wiki|Bash}}<br />
{{Article summary end}}<br />
There are a variety of possibilities for [[Bash]]'s prompt (PS1), and customizing it can help you be more productive at the command line. You can add additional information to your prompt, or you can simply add color to it to make the prompt stand out. See [https://bbs.archlinux.org/viewtopic.php?id=50885 this Forum thread] for more informations and examples.<br />
<br />
=A well-established Bash color prompt=<br />
<br />
What follows is a well-proven way to color the Bash prompt. It is the most widespread Bash color scheme in the GNU/Linux world. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~</span> <span style="color: #a00; font-weight: bold;">:(</span> <span style="color: #55f; font-weight: bold;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00; font-weight: bold;">alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
==Installation==<br />
<br />
It's a '''generalized scheme for all users''', so you should start removing your {{ic|~/.bashrc}} file and then modify the {{ic|/etc/bash.bashrc}} file and create a {{ic|/etc/DIR_COLORS}} file (but {{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} [[Color_Bash_Prompt#Example_of_cohabitation_of_.2Fetc.2Fbash.bashrc_and_.7E.2F.bashrc|can also cohabitate]]). Here is our possible version of this scheme for Arch (originally this scheme was created for Gentoo, but here are some important additions).<br />
<br />
===/etc/bash.bashrc===<br />
<br />
<pre style="max-height: 400px; overflow:auto;"># /etc/bash.bashrc<br />
#<br />
# https://wiki.archlinux.org/index.php/Color_Bash_Prompt<br />
#<br />
# This file is sourced by all *interactive* bash shells on startup,<br />
# including some apparently interactive shells such as scp and rcp<br />
# that can't tolerate any output. So make sure this doesn't display<br />
# anything or bad things will happen !<br />
<br />
# Test for an interactive shell. There is no need to set anything<br />
# past this point for scp and rcp, and it's important to refrain from<br />
# outputting anything in those cases.<br />
<br />
# If not running interactively, don't do anything!<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# Bash won't get SIGWINCH if another process is in the foreground.<br />
# Enable checkwinsize so that bash will check the terminal size when<br />
# it regains control.<br />
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)<br />
shopt -s checkwinsize<br />
<br />
# Enable history appending instead of overwriting.<br />
shopt -s histappend<br />
<br />
case ${TERM} in<br />
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
screen)<br />
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'<br />
;;<br />
esac<br />
<br />
# fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# Type: "pacman -S fortune-mod" to install it, then uncomment the<br />
# following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune<br />
<br />
# Set colorful PS1 only on colorful terminals.<br />
# dircolors --print-database uses its own built-in database<br />
# instead of using /etc/DIR_COLORS. Try to use the external file<br />
# first to take advantage of user additions. Use internal bash<br />
# globbing instead of external grep binary.<br />
<br />
# sanitize TERM:<br />
safe_term=${TERM//[^[:alnum:]]/?}<br />
match_lhs=""<br />
<br />
[[ -f ~/.dir_colors ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;~/.dir_colors)"<br />
[[ -f /etc/DIR_COLORS ]] &amp;&amp; match_lhs="${match_lhs}$(&lt;/etc/DIR_COLORS)"<br />
[[ -z ${match_lhs} ]] \<br />
&amp;&amp; type -P dircolors &gt;/dev/null \<br />
&amp;&amp; match_lhs=$(dircolors --print-database)<br />
<br />
if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then<br />
<br />
# we have colors :-)<br />
<br />
# Enable colors for ls, etc. Prefer ~/.dir_colors<br />
if type -P dircolors &gt;/dev/null ; then<br />
if [[ -f ~/.dir_colors ]] ; then<br />
eval $(dircolors -b ~/.dir_colors)<br />
elif [[ -f /etc/DIR_COLORS ]] ; then<br />
eval $(dircolors -b /etc/DIR_COLORS)<br />
fi<br />
fi<br />
<br />
PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "<br />
<br />
alias ls="ls --color=auto"<br />
alias dir="dir --color=auto"<br />
alias grep="grep --colour=auto"<br />
<br />
else<br />
<br />
# show root@ when we do not have colors<br />
<br />
PS1="\u@\h \w \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \":( \")\$ "<br />
<br />
fi<br />
<br />
PS2="&gt; "<br />
PS3="&gt; "<br />
PS4="+ "<br />
<br />
# Try to keep environment pollution down, EPA loves us.<br />
unset safe_term match_lhs<br />
<br />
# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).<br />
[ -r /usr/share/bash-completion/bash_completion ] &amp;&amp; . /usr/share/bash-completion/bash_completion<br />
<br />
# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).<br />
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook<br />
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] &amp;&amp; . /usr/share/doc/pkgfile/command-not-found.bash</pre><br />
<br />
===/etc/DIR_COLORS===<br />
<br />
<pre style="max-height: 300px; overflow:auto;"># Configuration file for the color ls utility<br />
# This file goes in the /etc directory, and must be world readable.<br />
# You can copy this file to .dir_colors in your $HOME directory to override<br />
# the system defaults.<br />
<br />
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not<br />
# pipes. 'all' adds color characters to all output. 'none' shuts colorization<br />
# off.<br />
COLOR all<br />
<br />
# Extra command line options for ls go here.<br />
# Basically these ones are:<br />
# -F = show '/' for dirs, '*' for executables, etc.<br />
# -T 0 = don't trust tab spacing when formatting ls output.<br />
OPTIONS -F -T 0<br />
<br />
# Below, there should be one TERM entry for each termtype that is colorizable<br />
TERM linux<br />
TERM console<br />
TERM con132x25<br />
TERM con132x30<br />
TERM con132x43<br />
TERM con132x60<br />
TERM con80x25<br />
TERM con80x28<br />
TERM con80x30<br />
TERM con80x43<br />
TERM con80x50<br />
TERM con80x60<br />
TERM xterm<br />
TERM xterm-color<br />
TERM vt100<br />
TERM rxvt<br />
TERM rxvt-256color<br />
TERM rxvt-cygwin<br />
TERM rxvt-cygwin-native<br />
TERM rxvt-unicode<br />
TERM rxvt-unicode-256color<br />
TERM rxvt-unicode256<br />
TERM screen<br />
<br />
# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)<br />
EIGHTBIT 1<br />
<br />
# Below are the color init strings for the basic file types. A color init<br />
# string consists of one or more of the following numeric codes:<br />
# Attribute codes: <br />
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed<br />
# Text color codes:<br />
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white<br />
# Background color codes:<br />
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white<br />
NORMAL 00 # global default, although everything should be something.<br />
FILE 00 # normal file<br />
DIR 01;34 # directory<br />
LINK 01;36 # symbolic link<br />
FIFO 40;33 # pipe<br />
SOCK 01;35 # socket<br />
BLK 40;33;01 # block device driver<br />
CHR 40;33;01 # character device driver<br />
<br />
# This is for files with execute permission:<br />
EXEC 01;32 <br />
<br />
# List any file extensions like '.gz' or '.tar' that you would like ls<br />
# to colorize below. Put the extension, a space, and the color init string.<br />
# (and any comments you want to add after a '#')<br />
.cmd 01;32 # executables (bright green)<br />
.exe 01;32<br />
.com 01;32<br />
.btm 01;32<br />
.bat 01;32<br />
.tar 01;31 # archives or compressed (bright red)<br />
.tgz 01;31<br />
.arj 01;31<br />
.taz 01;31<br />
.lzh 01;31<br />
.zip 01;31<br />
.z 01;31<br />
.Z 01;31<br />
.gz 01;31<br />
.jpg 01;35 # image formats<br />
.gif 01;35<br />
.bmp 01;35<br />
.xbm 01;35<br />
.xpm 01;35<br />
.tif 01;35</pre><br />
<br />
===/etc/skel/===<br />
<br />
This tip shows you how to use {{ic|/etc/skel/}} directory to ensure that all new users on your system get the same initial settings.<br />
<br />
The {{ic|/etc/skel/}} directory is the directory used by {{ic|useradd}} to create the default settings in a new user's home directory.<br />
<br />
To change the location of {{ic|/etc/skel/}}, edit {{ic|/etc/default/useradd}}.<br />
<br />
{{bc|<nowiki># useradd defaults file <br />
GROUP=100 <br />
HOME=/home <br />
INACTIVE=-1 <br />
EXPIRE= <br />
SHELL=/bin/bash <br />
SKEL=/etc/skel</nowiki>}}<br />
<br />
Typically files included in {{ic|/etc/skel/}} are {{ic|.rc}} files for shell initialization, but you could also include a {{ic|public_html}} directory, a custom {{ic|.dir_colors}} file, or anything else.<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> ls -A<br />.bash_logout .bash_profile .bashrc .xinitrc .xsession<br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">/etc/skel $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
For more information on customizing the {{ic|/etc/skel/}} directory, type: {{ic|$ man useradd}}. See also: [http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml http://www.gentoo.org/news/en/gwn/20031222-newsletter.xml].<br />
<br />
Now, the {{ic|/etc/skel/.bashrc}} file is the {{ic|.bashrc}} file copyied into the home directory of each ''new'' user. It will look something like this:<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
alias ls='ls --color=auto'<br />
PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
As you can see, a {{ic|PS1}} variable (i.e.: the prompt) is exported. So, if you had previously created a color prompt through the {{ic|/etc/bash.bashrc}} file, each user newly created, to see it, should delete the line<br />
<br />
{{bc|<nowiki>PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
from his own {{ic|~/.bashrc}}. Accordingly, if you want to grant to newly created users to have the same colorfull {{ic|PS1}}, you should delete that line from {{ic|/etc/skel/.bashrc}}.<br />
<br />
==Example of cohabitation of /etc/bash.bashrc and ~/.bashrc==<br />
<br />
{{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}} can also cohabitate. Here is a possible example of a typical Arch user's {{ic|~/.bashrc}} file which can cohabit with the {{ic|/etc/bash.bashrc}} file proposed here, valid for all users. The output will remain coloured.<br />
<br />
{{bc|<nowiki>#<br />
# ~/.bashrc<br />
#<br />
<br />
# If not running interactively, don't do anything<br />
[[ $- != *i* ]] &amp;&amp; return<br />
<br />
# pacman/yaourt aliases<br />
alias pac="sudo /usr/bin/pacman -S" # default action - install one or more packages<br />
alias paca="/usr/bin/yaourt -S" # default yaourt action - install one or more packages including AUR<br />
alias pacu="/usr/bin/yaourt -Syua" # '[u]pdate' - upgrade all packages to their newest version<br />
alias pacr="sudo /usr/bin/yaourt -Rs" # '[r]emove' - uninstall one or more packages<br />
alias pacs="/usr/bin/pacman -Ss" # '[s]earch' - search for a package using one or more keywords<br />
alias pacys="/usr/bin/yaourt -Ss" # '[y]aourt [s]earch' - search for a package or a PKGBUILD using one or more keywords<br />
alias paci="/usr/bin/yaourt -Si" # '[i]nfo' - show information about a package<br />
alias paclo="/usr/bin/pacman -Qdt" # '[l]ist [o]rphans' - list all packages which are orphaned<br />
alias pacc="sudo /usr/bin/pacman -Scc" # '[c]lean cache' - delete all not currently installed package files<br />
alias paclf="/usr/bin/pacman -Ql" # '[l]ist [f]iles' - list all files installed by a given package<br />
alias pacexpl="/usr/bin/yaourt -D --asexplicit" # 'mark as [expl]icit' - mark one or more packages as explicitly installed <br />
alias pacimpl="/usr/bin/yaourt -D --asdeps" # 'mark as [impl]icit' - mark one or more packages as non explicitly installed<br />
<br />
# '[r]emove [o]rphans' - recursively remove ALL orphaned packages<br />
alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rs \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;$!ba;s/\n/ /g')"</nowiki>}}<br />
<br />
==Random quotations at logon==<br />
<br />
If you want a random quotation at logon (like Slackware) you must install Fortune. Fortune is a simple program that displays a pseudorandom message from a database of quotations at logon and/or logout. Type {{ic|pacman -S fortune-mod}} to install it, then uncomment the following line from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
<br />
If you want to colorize (brown in this example) the random message from fortune, replace the previous commented text with:<br />
{{bc|<nowiki>[[ "$PS1" ]] &amp;&amp; echo -e "\e[00;33m$(/usr/bin/fortune)\e[00m"</nowiki>}}<br />
<br />
==Colorized [https://www.archlinux.org/news/ Arch latest news] at logon==<br />
<br />
If you want to read the latest news from the [https://www.archlinux.org/ Arch Official Website], instead of a random quotation from fortune, replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
{{bc|<nowiki># fortune is a simple program that displays a pseudorandom message<br />
# from a database of quotations at logon and/or logout.<br />
# Type: "pacman -S fortune-mod" to install it, then uncomment the<br />
# following line:<br />
<br />
# [[ "$PS1" ]] &amp;&amp; /usr/bin/fortune</nowiki>}}<br />
with:<br />
{{bc|<nowiki># Arch latest news<br />
<br />
if [ "$PS1" ]; then<br />
# The characters "&pound;, &sect;" are used as metacharacters. They should not be encountered in a feed...<br />
echo -e "$(echo $(curl --silent https://www.archlinux.org/feeds/news/ | sed -e ':a;N;$!ba;s/\n/ /g') | \<br />
sed -e 's/&amp;amp;/\&amp;/g<br />
s/&amp;lt;\|&amp;#60;/&lt;/g<br />
s/&amp;gt;\|&amp;#62;/&gt;/g<br />
s/&lt;\/a&gt;/&pound;/g<br />
s/href\=\"/&sect;/g<br />
s/&lt;title&gt;/\\n\\n\\n :: \\e[01;31m/g; s/&lt;\/title&gt;/\\e[00m ::\\n/g<br />
s/&lt;link&gt;/ [ \\e[01;36m/g; s/&lt;\/link&gt;/\\e[00m ]/g<br />
s/&lt;description&gt;/\\n\\n\\e[00;37m/g; s/&lt;\/description&gt;/\\e[00m\\n\\n/g<br />
s/&lt;p\( [^&gt;]*\)\?&gt;\|&lt;br\s*\/\?&gt;/\n/g<br />
s/&lt;b\( [^&gt;]*\)\?&gt;\|&lt;strong\( [^&gt;]*\)\?&gt;/\\e[01;30m/g; s/&lt;\/b&gt;\|&lt;\/strong&gt;/\\e[00;37m/g<br />
s/&lt;i\( [^&gt;]*\)\?&gt;\|&lt;em\( [^&gt;]*\)\?&gt;/\\e[41;37m/g; s/&lt;\/i&gt;\|&lt;\/em&gt;/\\e[00;37m/g<br />
s/&lt;u\( [^&gt;]*\)\?&gt;/\\e[4;37m/g; s/&lt;\/u&gt;/\\e[00;37m/g<br />
s/&lt;code\( [^&gt;]*\)\?&gt;/\\e[00m/g; s/&lt;\/code&gt;/\\e[00;37m/g<br />
s/&lt;a[^&sect;|t]*&sect;\([^\"]*\)\"[^&gt;]*&gt;\([^&pound;]*\)[^&pound;]*&pound;/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g<br />
s/&lt;li\( [^&gt;]*\)\?&gt;/\n \\e[01;34m*\\e[00;37m /g<br />
s/&lt;!\[CDATA\[\|\]\]&gt;//g<br />
s/\|&gt;\s*&lt;//g<br />
s/ *&lt;[^&gt;]\+&gt; */ /g<br />
s/[&lt;&gt;&pound;&sect;]//g')\n\n";<br />
fi</nowiki>}}<br />
that is a small and coloured RSS escaping script written by the user [https://aur.archlinux.org/account.php?Action=AccountInfo&ID=33208 grufo] which will display an output like this:<br />
<br />
<div style="height: 350px; overflow: auto; font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; background-color: black; color: #aaaaaa;">&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Arch Linux: Recent news updates</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br />The latest and greatest news from the Arch Linux distribution.<br /><br />&nbsp;<span style="color: #aa0000; font-weight: bold;">en-us Sun, 04 Nov 2012 16:09:46 +0000</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">End of initscripts support</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/end-of-initscripts-support/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Tom Gundersen wrote:<br />As <span style="color: #ffffff;">systemd</span> is now the default init system, Arch Linux is receiving minimal testing on initscripts systems. Due to a lack of resources and interest, we are unlikely to work on fixing <span style="color: #ffffff;">initscripts</span>-specific bugs, and may close them as WONTFIX.<br />We therefore strongly encourage all users to migrate to <span style="color: #ffffff;">systemd</span> as soon as possible. See the <span style="color: #ffffff;">systemd</span> migration guide <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span>.<br />To ease the transition, <span style="color: #ffffff;">initscripts</span> support will remain in the official repositories for the time being, unless otherwise stated. As of January 2013, we will start removing <span style="color: #ffffff;">initscripts</span> support (e.g., <span style="color: #ffffff;">rc</span> scripts) from individual packages without further notice.<br /><br />&nbsp;<span style="color: #ffffff;">Tom Gundersen Sun, 04 Nov 2012 16:09:46 +0000 tag:www.archlinux.org,2012-11-04:/news/end-of-initscripts-support/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">November release of install media available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/november-release-of-install-media-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The latest snapshot of our install and rescue media can be found on our <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> page. The 2012.11.01 ISO image mainly contains minor bug fixes, cleanups and new packages compared to the previous one:<br />&nbsp;<span style="color: #5555ff;">*</span> First media with Linux 3.6<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">copytoram=n</span> can be used to not copy the image to RAM on network boot. This is probably unreliable but an option for systems with very low memory.<br />&nbsp;<span style="color: #5555ff;">*</span> <span style="background-color: #aa0000;">cowfile_size</span> boot parameter mainly for persistent COW on VFAT. See the <span style="color: #aa0000; font-weight: bold;">README</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://projects.archlinux.org/archiso.git/plain/docs/README.bootparams?id=v4</nowiki></span> <span style="color: #5555ff;">]</span> file for details.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Fri, 02 Nov 2012 17:54:15 +0000 tag:www.archlinux.org,2012-11-02:/news/november-release-of-install-media-available/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Bug Squashing Day: Saturday 17th November</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/bug-squashing-day-saturday-17th-november/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />The number of bugs in the Arch Linux bug tracker is creeping up so it is time for some extermination.<br />This is a great way for the community to get involved and help the Arch Linux team. The process is simple. First look at a bug for your favorite piece of software in the bug tracker and check if it still occurs. If it does, check the upstream project for a fix and test it to confirm it works. If there is no fix available, make sure the bug has been filed in the upstream tracker.<br />Join us on the #archlinux-bugs IRC channel. We are spread across timezones, so people should be around all day.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Thu, 01 Nov 2012 12:28:51 +0000 tag:www.archlinux.org,2012-11-01:/news/bug-squashing-day-saturday-17th-november/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">ConsoleKit replaced by logind</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/consolekit-replaced-by-logind/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Allan McRae wrote:<br />With GNOME 3.6, polkit and networkmanager moving to [extra], ConsoleKit has now been removed from the repositories. Any package that previously depended on it now relies on systemd-logind instead. That means that the system must be booted with systemd to be fully functional.<br />In addition to GNOME, both KDE and XFCE are also affected by this change.<br /><br />&nbsp;<span style="color: #ffffff;">Allan McRae Tue, 30 Oct 2012 22:17:39 +0000 tag:www.archlinux.org,2012-10-30:/news/consolekit-replaced-by-logind/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">systemd is now the default on new installations</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/systemd-is-now-the-default-on-new-installations/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Thomas B&auml;chler wrote:<br />The base group now contains the <span style="color: #ffffff;">systemd-sysvcompat</span> package. This means that all new installations will boot with systemd by default.<br />As some packages still lack native systemd units, users can install the <span style="color: #ffffff;">initscripts</span> package and use the <span style="color: #ffffff;">DAEMONS</span> array in <span style="color: #ffffff;">/etc/rc.conf</span> to start services using the legacy rc.d scripts.<br />This change does not affect existing installations. For the time being, the <span style="color: #ffffff;">initscripts</span> and <span style="color: #ffffff;">sysvinit</span> packages remain available from our repositories. However, individual packages may now start relying on the system being booted with systemd.<br />Please refer to <span style="color: #aa0000; font-weight: bold;">the wiki</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Systemd</nowiki></span> <span style="color: #5555ff;">]</span> for how to transition an existing installation to systemd.<br /><br />&nbsp;<span style="color: #ffffff;">Thomas B&auml;chler Sat, 13 Oct 2012 09:29:38 +0000 tag:www.archlinux.org,2012-10-13:/news/systemd-is-now-the-default-on-new-installations/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install medium 2012.10.06 introduces systemd</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-medium-20121006-introduces-systemd/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The October release of the Arch Linux install medium is available for <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and can be used for new installs or as a rescue system. It contains a set of updated packages and the following notable changes:<br />&nbsp;<span style="color: #5555ff;">*</span> systemd is used to boot up the live system.<br />&nbsp;<span style="color: #5555ff;">*</span> initscripts are no longer available on the live system but are still installed by default on the target system. This is likely to change in the near future.<br />&nbsp;<span style="color: #5555ff;">*</span> EFI boot and setup has been simplified.<br />&nbsp;<span style="color: #5555ff;">*</span> gummiboot is used to display a menu on EFI systems.<br />&nbsp;<span style="color: #5555ff;">*</span> The following new packages are available on the live system: ethtool, fsarchiver, gummiboot-efi, mc, partclone, partimage, refind-efi, rfkill, sudo, testdisk, wget, xl2tpd<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sun, 07 Oct 2012 16:58:03 +0000 tag:www.archlinux.org,2012-10-07:/news/install-medium-20121006-introduces-systemd/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">New install medium 2012.09.07</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/new-install-medium-20120907/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />As is customary by now there is a new install medium available at the beginning of this month. The live system can be downloaded from <span style="color: #aa0000; font-weight: bold;">Download</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://www.archlinux.org/download/</nowiki></span> <span style="color: #5555ff;">]</span> and be used for new installs or as a rescue system.<br />In addition to a couple of updated packages and bug fixes the following changes stand out:<br />&nbsp;<span style="color: #5555ff;">*</span> First medium with Linux 3.5 (3.5.3)<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="background-color: #aa0000;">script</span> boot parameter works again (<span style="color: #aa0000; font-weight: bold;">FS#31022</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://bugs.archlinux.org/task/31022</nowiki></span> <span style="color: #5555ff;">]</span>)<br />&nbsp;<span style="color: #5555ff;">*</span> When booting via PXE and NFS or NBD the ISO will be copied to RAM to ensure a more stable usage.<br />&nbsp;<span style="color: #5555ff;">*</span> The live medium contains <span style="background-color: #aa0000;">usb_modeswitch</span> and <span style="background-color: #aa0000;">wvdial</span> which e.g. allows to establish a network connection using an UMTS USB dongle<br />&nbsp;<span style="color: #5555ff;">*</span> Furthermore the newest versions of <span style="background-color: #aa0000;">initscripts</span>, <span style="background-color: #aa0000;">systemd</span> and <span style="background-color: #aa0000;">netcfg</span> are included.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 08 Sep 2012 09:48:52 +0000 tag:www.archlinux.org,2012-09-08:/news/new-install-medium-20120907/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Fontconfig 2.10.1 update - manual intervention required</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/fontconfig-2101-update-manual-intervention-required/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Andreas Radke wrote:<br />The fontconfig 2.10.1 update overwrites symlinks created by the former package version. These symlinks need to be removed before the update:<br /><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-unhint-small-vera.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/20-fix-globaladvance.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/29-replace-bitmap-fonts.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-metric-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/30-urw-aliases.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/40-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/45-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/49-sansserif.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/50-user.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/51-local.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/60-latin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-fonts-persian.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/65-nonlatin.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/69-unifont.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/80-delicious.conf</span><br /><span style="color: #ffffff;">rm /etc/fonts/conf.d/90-synthetic.conf</span><br /><span style="color: #ffffff;">pacman -Sy fontconfig</span><br /><br />Main systemwide configuration should be done by symlinks (especially for autohinting, sub-pixel and lcdfilter):<br /><br /><span style="color: #ffffff;">cd /etc/fonts/conf.d</span><br /><span style="color: #ffffff;">ln -s ../conf.avail/XX-foo.conf</span><br /><br />Also check <span style="color: #aa0000; font-weight: bold;">Font Configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Font_Configuration</nowiki></span> <span style="color: #5555ff;">]</span> and <span style="color: #aa0000; font-weight: bold;">Fonts</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Fonts</nowiki></span> <span style="color: #5555ff;">]</span>.<br /><br />&nbsp;<span style="color: #ffffff;">Andreas Radke Thu, 06 Sep 2012 13:54:23 +0000 tag:www.archlinux.org,2012-09-06:/news/fontconfig-2101-update-manual-intervention-required/</span><br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">netcfg-2.8.9 drops deprecated rc.conf compatibility</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/netcfg-289-drops-initscripts-compatibility/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Florian Pritz wrote:<br />Users of <span style="color: #ffffff;">netcfg</span> should configure all interfaces in <span style="color: #ffffff;">/etc/conf.d/netcfg</span> rather than <span style="color: #ffffff;">/etc/rc.conf</span>.<br /><br />&nbsp;Florian Pritz Sat, 11 Aug 2012 20:00:02 +0000 tag:www.archlinux.org,2012-08-11:/news/netcfg-289-drops-initscripts-compatibility/<br /><br /><br />&nbsp;&nbsp; <span style="color: #ffffff; font-weight: bold;">::</span> <span style="color: #aa0000; font-weight: bold;">Install media 2012.08.04 available</span> <span style="color: #ffffff; font-weight: bold;">::</span><br />&nbsp;<span style="color: #ffffff;">[</span> <span style="color: #55ccff; font-weight: bold;"><nowiki>https://www.archlinux.org/news/install-media-20120804-available/</nowiki></span> <span style="color: #ffffff;">]</span><br /><br /><br />Pierre Schmitz wrote:<br />The August snapshot of our live and install media comes with updated packages and the following changes on top of the <span style="color: #aa0000; font-weight: bold;">previous ISO image</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/news/install-media-20120715-released/</span> <span style="color: #5555ff;">]</span>:<br />&nbsp;<span style="color: #5555ff;">*</span> GRUB 2.0 instead of the legacy 0.9 version is available.<br />&nbsp;<span style="color: #5555ff;">*</span> The <span style="color: #aa0000; font-weight: bold;">Installation Guide</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>https://wiki.archlinux.org/index.php/Installation_Guide</nowiki></span> <span style="color: #5555ff;">]</span> can be found at <span style="background-color: #aa0000;">/root/install.txt</span>.<br />&nbsp;<span style="color: #5555ff;">*</span> ZSH with <span style="color: #aa0000; font-weight: bold;">Grml's configuration</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;"><nowiki>http://grml.org/zsh/</nowiki></span> <span style="color: #5555ff;">]</span> is used as interactive shell to provide a user friendly and more convenient environment. This includes completion support for pacstrap, arch-chroot, pacman and most other tools.<br />&nbsp;<span style="color: #5555ff;">*</span> The network daemon is started by default which will automatically setup your network if DHCP is available.<br />Note that all these changes only affect the live system and not the base system you install using pacstrap. The ISO image can be downloaded from our <span style="color: #aa0000; font-weight: bold;">download page</span> <span style="color: #5555ff;">[</span> <span style="text-decoration: underline;">/download/</span> <span style="color: #5555ff;">]</span>. The next snapshot is scheduled for September.<br /><br />&nbsp;<span style="color: #ffffff;">Pierre Schmitz Sat, 04 Aug 2012 17:24:30 +0000 tag:www.archlinux.org,2012-08-04:/news/install-media-20120804-available/</span><br /><br /><br /><span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
See [https://bbs.archlinux.org/viewtopic.php?id=146850 this thread] for details.<br />
<br />
==Variations on a theme==<br />
<br />
Here are some {{ic|PS1}} variables (i.e.: prompts) with different layout to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file. When you choose a layout you must replace the following lines from [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file:<br />
<br />
{{bc|<nowiki> PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "<br />
<br />
# Use this other PS1 string if you want \W for root and \w for all other users:<br />
# PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] &amp;&amp; echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "</nowiki>}}<br />
<br />
with the {{ic|PS1}} variable (and possibly other code lines) given by the choosen layout.<br />
<br />
===From Arch Forum #1===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202 what wrote the user JeSuisNerd and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">&#10007;</span>]&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span> echo 'Hello world!' Hello world!<br /><span style="color: #aaa;">&#9484;&#9472;[</span><span style="color: #f90;">andy</span>@<span style="color: #5fc;">alba</span><span style="color: #aaa;">]&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #aaa;">&#9484;&#9472;[<span style="color: #a00;">alba</span>]</span><span style="color: #aaa;">&#9472;[</span><span style="color: #0c0;">~</span><span style="color: #aaa;">]</span><br /><span style="color: #aaa;">&#9492;&#9472;&#9472;&#9596;</span>&nbsp;<span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like <span style="color: #a00;">✗</span> and ╼) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1068202#p1068202<br />
PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]"</nowiki>}}<br />
<br />
===From an italian blog&hellip;===<br />
<br />
Here is an unicode variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [http://dark-linux.net/personalizzare-bashrc-eo-bash-bashrc/ an italian blog]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:20<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:03:31<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]</span><br /><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="color: #55f;">&#9484;&#9472;[</span>&#10007;<span style="color: #55f;">]&#9472;[</span>12:04:01<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> echo 'Hello world!'<br />Hello world!<br /><span style="color: #55f;">&#9484;&#9472;[</span>12:04:13<span style="color: #55f;">]&#9472;[</span>andy@alba<span style="color: #55f;">]<br /></span><span style="color: #55f;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #55f;">$</span> su<br />Password:<br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><span style="color: #a00;">&#9484;&#9472;[</span>12:04:21<span style="color: #a00;">]&#9472;[</span>root@alba<span style="color: #a00;">]<br /></span><span style="color: #a00;">&#9492;&#9472;&#9472;&gt;</span> ~ <span style="color: #a00;">$</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
'''Note:''' '''Some unicode symbols (like ✗) are not well supported in some terminals''' (in linux console, for example), so this prompt will appear a bit different depending on where is displayed. If you want to know the unicode representation of a plain text, [http://0xcc.net/jsescape/ here] you have a little plain text converter.<br />
<br />
And finally here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> if [[ ${EUID} == 0 ]] ; then<br />
sq_color="\[\033[0;31m\]"<br />
else <br />
sq_color="\[\033[0;34m\]"<br />
fi<br />
<br />
PS1="$sq_color\342\224\214\342\224\200\$([[ \$? != 0 ]] &amp;&amp; echo \"[\[\033[01;37m\]\342\234\227$sq_color]\342\224\200\")[\[\033[01;37m\]\t$sq_color]\342\224\200[\[\033[01;37m\]\u@\h$sq_color]\n\342\224\224\342\224\200\342\224\200&gt; \[\033[01;37m\]\W$sq_color $ \[\033[01;37m\]&gt;&gt;\\[\\033[0m\\] "<br />
<br />
unset sq_color</nowiki>}}<br />
<br />
===From Arch Forum #2===<br />
<br />
Here is another variation of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 what wrote the user shumer1213 and others in the Arch Forum]. Here is a preview of how it will appear:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:05:58 ]</span><br />&#9608;&#9608; ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> public.desktop<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:02 ]</span><br />&#9608;&#9608; I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="color: #aa0000;">&#9608;&#9608; [ ~ ] [ 18:06:12 ]</span><br />&#9608;&#9608; echo 'Hello world!'<br />Hello world!<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ ~ ] [ 18:06:17 ]</span><br />&#9608;&#9608; su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="color: #5555ff;">&#9608;&#9608; [ andy ] [ 18:06:26 ]</span><br />&#9608;&#9608; <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660<br />
PS1="\n\$(if [[ \$? == 0 ]]; then echo \"\[\033[0;34m\]\"; else echo \"\[\033[0;31m\]\"; fi)\342\226\210\342\226\210 [ \W ] [ \t ]\n\[\033[0m\]\342\226\210\342\226\210 "</nowiki>}}<br />
<br />
===With directory information===<br />
<br />
Here are other three variations of [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file freely based on the article [http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04 8 Useful and Interesting Bash Prompts]. Here is a preview of how they will appear:<br />
<br />
====Version #1: with numerical error====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">127</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">1</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">0</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\$?\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
<br />
====Version #2: with unicode error status symbols====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #0a0; font-weight: bold;">&#10003;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\342\224\200(\$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi)\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
====Version #3: with unicode error status symbol (non-zero only)====<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff; font-size: 14px; line-height: 17px;">I am two with nature.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Woody Allen<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> ls<br /><span style="color: #55f; font-weight: bold;">Desktop Documents Music</span> myScript.js<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:38 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> echo 'Hello world!'<br />Hello world!<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> false<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #5555ff;">andy@alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="color: #a00; font-weight: bold;">&#10007;</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">~</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> su<br />Password: <br />Two can Live as Cheaply as One for Half as Long.<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Howard Kandel<br /><br /><span style="font-weight: bold;">&#9484;(</span><span style="font-weight: bold; color: #aa0000;">alba</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #5555ff;">02:39 PM Sat Aug 29</span><span style="font-weight: bold;">)</span><br /><span style="font-weight: bold;">&#9492;&#9472;(</span><span style="font-weight: bold; color: #00cc00;">/home/andy</span><span style="font-weight: bold;">)&#9472;(</span><span style="font-weight: bold; color: #00cc00;">4 files, 332Kb</span><span style="font-weight: bold;">)&#9472;&gt;</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
Here is the {{ic|PS1}} variable for this effect to be applyied to [[Color_Bash_Prompt#.2Fetc.2Fbash.bashrc|our]] {{ic|/etc/bash.bashrc}} file (see [[Color_Bash_Prompt#Variations_on_a_theme|above]]):<br />
<br />
{{bc|<nowiki> # http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04<br />
PS1="\n\[\033[1;37m\]\342\224\214($(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi)\[\033[1;37m\])\$([[ \$? != 0 ]] &amp;&amp; echo \"\342\224\200(\[\033[0;31m\]\342\234\227\[\033[1;37m\])\")\342\224\200(\[\033[1;34m\]\@ \d\[\033[1;37m\])\[\033[1;37m\]\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$(ls -1 | wc -l | sed 's: ::g') files, \$(ls -lah | grep -m 1 total | sed 's/total //')b\[\033[1;37m\])\342\224\200&gt; \[\033[0m\]"</nowiki>}}<br />
<br />
==Restoring the original /etc/bash.bashrc file==<br />
<br />
If you repent having modified the {{ic|/etc/bash.bashrc}} file, you can always restore the original Arch {{ic|/etc/bash.bashrc}} file from the [[ bash ]] package and remove the {{ic|/etc/DIR_COLORS}} file. Note that there is not an "official" bash.bashrc: each distribution has its own.<br />
<br />
==Original /etc/bash.bashrc from Gentoo==<br />
<br />
The original ''not modified'' Gentoo's {{ic|/etc/bash.bashrc}} file can be found [http://www.jeremysands.com/archlinux/gentoo-bashrc-2008.0 here].<br />
<br />
=Step by step=<br />
<br />
If you want to create a style all your own, you can take a look at these tips. [https://bbs.archlinux.org/viewtopic.php?id=50885 This Forum thread] could give you more informations and examples.<br />
<br />
==Basic prompts==<br />
<br />
The following settings are useful for distinguishing the root prompt from non-root users.<br />
<br />
*Edit Bash's personal configuration file:<br />
{{bc|<nowiki>$ nano ~/.bashrc</nowiki>}}<br />
<br />
*Comment out the default prompt:<br />
{{bc|<nowiki># PS1='[\u@\h \W]\$ '</nowiki>}}<br />
<br />
*Add the following green prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0f0">[chiri@zetsubou ~]$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
*Edit root's .bashrc file; copy it from /etc/skel if the file is not present:<br />
{{bc|<nowiki>$ nano /root/.bashrc</nowiki>}}<br />
*Assign a red prompt for root:<br />
<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #f00">[root@zetsubou ~]#</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '</nowiki>}}<br />
<br />
===Slightly fancier prompts===<br />
<br />
*A green and blue prompt for regular users:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> echo "sample output text"<br />sample output text<br /><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> <span style="text-decoration: blink;">_</span></div><br />
{{bc|<nowiki>PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'</nowiki>}}<br />
<br />
This will give a very pleasing, colorful prompt and theme for the console with bright white text.<br />
<br />
The string above contains color-set escape sequences (start coloring: \[\e[color\], end coloring: \[\e[m\]) and information placeholders:<br />
<br />
* \u - Username. The original prompt also has \h, which prints the host name.<br />
* \w - Current absolute path. Use \W for current relative path.<br />
* \$ - The prompt character (eg. '#' for root, '$' for regular users). <br />
<br />
The last color-set sequence, "\[\e[1;37m\]", is not closed, so the remaining text (everything typed into the terminal, program output and so on) will be in that (bright white) color. It may be desirable to change this color, or to delete the last escape sequence in order to leave the actual output in unaltered color. <br />
<br />
*A red and blue prompt for root:<br />
<div style="font-family: monospace; white-space: pre; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0">echo "sample output text"<br />sample output text<br /></span><span style="color: #a00">root</span> <span style="color: #00f">~/docs</span> <span style="color: #a00">#</span> <span style="color: #0a0"><span style="text-decoration: blink;">_</span></span></div><br />
{{bc|<nowiki>PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\]'</nowiki>}}<br />
<br />
This will give you a red designation and green console text.<br />
<br />
Once you have made your changes to .bashrc, to execute your changes:<br />
<br />
{{bc|<nowiki>$ source ~/.bashrc</nowiki>}}<br />
<br />
==Advanced prompts==<br />
<br />
===Load/Mem Status for 256colors===<br />
This is not even pushing the limits. Other than using 'sed' to parse the memory and load average (using the ''-u'' option for non-buffering), and the builtin ''history'' to save your history to your ''HISTFILE'' after every command, which you may find incredibly useful when dealing with crashing shells or subshells, this is essentially just making BASH print variables it already knows, making this extremely fast compared to prompts with non-builtin commands.<br />
<br />
This prompt is from AskApache.com's [http://www.askapache.com/linux-unix/bash-power-prompt.html BASH Power Prompt article], which goes into greater detail. It is especially helpful for those wanting to understand 256 color terminals, ncurses, termcap, and terminfo.<br />
<br />
This is for '''256 color terminals''', which is where the '''\033[38;5;22m''' terminal escapes come from. <br />
{{bc|1=<br />
<span style="color:#0b0">802</span><span style="color:#005f00">/1024MB</span> <span style="color:#5f00af">1.28 1.20 1.13 3/94 18563</span><br />
<span style="color:#555">[5416:17880 0:70]</span> <span style="color:0bb">05:35:50 Wed Apr 21</span> <span style="color:#555">[</span><span style="color:#2b47ff">srot@host.sqpt.net</span><span style="color:#555">:</span><span style="color:#bbb">/dev/pts/0</span> <span style="color:#00bb00">+1</span><span style="color:#555">]</span> <span style="color:#000">~<br /><br />
(1:70)$ <span style="text-decoration: blink;">_</span></span><br />
}}<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( `sed -nu "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed -nu "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo`/1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m"'<br />
PS1='\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ '</nowiki>}}<br />
<br />
===List of colors for prompt and Bash===<br />
<br />
Add this to your Bash file(s) to define colors for prompt and commands:<br />
{{bc|<nowiki>txtblk='\e[0;30m' # Black - Regular<br />
txtred='\e[0;31m' # Red<br />
txtgrn='\e[0;32m' # Green<br />
txtylw='\e[0;33m' # Yellow<br />
txtblu='\e[0;34m' # Blue<br />
txtpur='\e[0;35m' # Purple<br />
txtcyn='\e[0;36m' # Cyan<br />
txtwht='\e[0;37m' # White<br />
bldblk='\e[1;30m' # Black - Bold<br />
bldred='\e[1;31m' # Red<br />
bldgrn='\e[1;32m' # Green<br />
bldylw='\e[1;33m' # Yellow<br />
bldblu='\e[1;34m' # Blue<br />
bldpur='\e[1;35m' # Purple<br />
bldcyn='\e[1;36m' # Cyan<br />
bldwht='\e[1;37m' # White<br />
unkblk='\e[4;30m' # Black - Underline<br />
undred='\e[4;31m' # Red<br />
undgrn='\e[4;32m' # Green<br />
undylw='\e[4;33m' # Yellow<br />
undblu='\e[4;34m' # Blue<br />
undpur='\e[4;35m' # Purple<br />
undcyn='\e[4;36m' # Cyan<br />
undwht='\e[4;37m' # White<br />
bakblk='\e[40m' # Black - Background<br />
bakred='\e[41m' # Red<br />
bakgrn='\e[42m' # Green<br />
bakylw='\e[43m' # Yellow<br />
bakblu='\e[44m' # Blue<br />
bakpur='\e[45m' # Purple<br />
bakcyn='\e[46m' # Cyan<br />
bakwht='\e[47m' # White<br />
txtrst='\e[0m' # Text Reset</nowiki>}}<br />
<br />
Or if you prefer color names you will know how to spell without a special decoder ring and want high intensity colors:<br />
{{bc|<nowiki># Reset<br />
Color_Off='\e[0m' # Text Reset<br />
<br />
# Regular Colors<br />
Black='\e[0;30m' # Black<br />
Red='\e[0;31m' # Red<br />
Green='\e[0;32m' # Green<br />
Yellow='\e[0;33m' # Yellow<br />
Blue='\e[0;34m' # Blue<br />
Purple='\e[0;35m' # Purple<br />
Cyan='\e[0;36m' # Cyan<br />
White='\e[0;37m' # White<br />
<br />
# Bold<br />
BBlack='\e[1;30m' # Black<br />
BRed='\e[1;31m' # Red<br />
BGreen='\e[1;32m' # Green<br />
BYellow='\e[1;33m' # Yellow<br />
BBlue='\e[1;34m' # Blue<br />
BPurple='\e[1;35m' # Purple<br />
BCyan='\e[1;36m' # Cyan<br />
BWhite='\e[1;37m' # White<br />
<br />
# Underline<br />
UBlack='\e[4;30m' # Black<br />
URed='\e[4;31m' # Red<br />
UGreen='\e[4;32m' # Green<br />
UYellow='\e[4;33m' # Yellow<br />
UBlue='\e[4;34m' # Blue<br />
UPurple='\e[4;35m' # Purple<br />
UCyan='\e[4;36m' # Cyan<br />
UWhite='\e[4;37m' # White<br />
<br />
# Background<br />
On_Black='\e[40m' # Black<br />
On_Red='\e[41m' # Red<br />
On_Green='\e[42m' # Green<br />
On_Yellow='\e[43m' # Yellow<br />
On_Blue='\e[44m' # Blue<br />
On_Purple='\e[45m' # Purple<br />
On_Cyan='\e[46m' # Cyan<br />
On_White='\e[47m' # White<br />
<br />
# High Intensity<br />
IBlack='\e[0;90m' # Black<br />
IRed='\e[0;91m' # Red<br />
IGreen='\e[0;92m' # Green<br />
IYellow='\e[0;93m' # Yellow<br />
IBlue='\e[0;94m' # Blue<br />
IPurple='\e[0;95m' # Purple<br />
ICyan='\e[0;96m' # Cyan<br />
IWhite='\e[0;97m' # White<br />
<br />
# Bold High Intensity<br />
BIBlack='\e[1;90m' # Black<br />
BIRed='\e[1;91m' # Red<br />
BIGreen='\e[1;92m' # Green<br />
BIYellow='\e[1;93m' # Yellow<br />
BIBlue='\e[1;94m' # Blue<br />
BIPurple='\e[1;95m' # Purple<br />
BICyan='\e[1;96m' # Cyan<br />
BIWhite='\e[1;97m' # White<br />
<br />
# High Intensity backgrounds<br />
On_IBlack='\e[0;100m' # Black<br />
On_IRed='\e[0;101m' # Red<br />
On_IGreen='\e[0;102m' # Green<br />
On_IYellow='\e[0;103m' # Yellow<br />
On_IBlue='\e[0;104m' # Blue<br />
On_IPurple='\e[0;105m' # Purple<br />
On_ICyan='\e[0;106m' # Cyan<br />
On_IWhite='\e[0;107m' # White<br />
</nowiki>}}<br />
<br />
To use in commands from your shell environment:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$ echo -e "${txtblu}test"<br /><span style="color: blue;">test</span><br />$ echo -e "${bldblu}test"<br /><span style="color: lightblue;"><strong>test</strong></span><br />$ echo -e "${undblu}test"<br /><span style="color: lightblue;"><strong><span style="text-decoration: underline;">test</span></strong></span><br />$ echo -e "${bakblu}test"<br /><span style="color: white; background-color: lightblue;"><strong>test</strong></span><br />$ <span style="text-decoration: blink;">_</span></div><br />
<br />
To use in a prompt (note double quotes to enable $color variable expansion and <nowiki>\[ \]</nowiki> escapes around them so they are not counted as character positions and the cursor position is not wrong):<br />
<br />
{{bc|<nowiki>PS1="\[$txtblu\]foo\[$txtred\] bar\[$txtrst\] baz : "</nowiki>}}<br />
<br />
If you experience premature line wrapping when entering commands at the prompt then missing escapes is most likely to be the reason.<br />
<br />
===Prompt escapes===<br />
<br />
The various Bash prompt escapes listed in the manpage:<br />
<br />
{{bc|<nowiki>Bash allows these prompt strings to be customized by inserting a<br />
number of ''backslash-escaped special characters'' that are<br />
decoded as follows:<br />
<br />
\a an ASCII bell character (07)<br />
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")<br />
\D{format} the format is passed to strftime(3) and the result<br />
is inserted into the prompt string an empty format<br />
results in a locale-specific time representation.<br />
The braces are required<br />
\e an ASCII escape character (033)<br />
\h the hostname up to the first `.'<br />
\H the hostname<br />
\j the number of jobs currently managed by the shell<br />
\l the basename of the shell's terminal device name<br />
\n newline<br />
\r carriage return<br />
\s the name of the shell, the basename of $0 (the portion following<br />
the final slash)<br />
\t the current time in 24-hour HH:MM:SS format<br />
\T the current time in 12-hour HH:MM:SS format<br />
\@ the current time in 12-hour am/pm format<br />
\A the current time in 24-hour HH:MM format<br />
\u the username of the current user<br />
\v the version of bash (e.g., 2.00)<br />
\V the release of bash, version + patch level (e.g., 2.00.0)<br />
\w the current working directory, with $HOME abbreviated with a tilde<br />
\W the basename of the current working directory, with $HOME<br />
abbreviated with a tilde<br />
\! the history number of this command<br />
\# the command number of this command<br />
\$ if the effective UID is 0, a #, otherwise a $<br />
\nnn the character corresponding to the octal number nnn<br />
\\ a backslash<br />
\[ begin a sequence of non-printing characters, which could be used<br />
to embed a terminal control sequence into the prompt<br />
\] end a sequence of non-printing characters<br />
<br />
The command number and the history number are usually different:<br />
the history number of a command is its position in the history<br />
list, which may include commands restored from the history file<br />
(see HISTORY below), while the command number is the position in<br />
the sequence of commands executed during the current shell session.<br />
After the string is decoded, it is expanded via parameter<br />
expansion, command substitution, arithmetic expansion, and quote<br />
removal, subject to the value of the promptvars shell option (see<br />
the description of the shopt command under SHELL BUILTIN COMMANDS<br />
below).</nowiki>}}<br />
<br />
===Positioning the cursor===<br />
<br />
The following sequence sets the cursor position:<br />
<br />
{{bc|<nowiki>\[\033[<row>;<column>f\]</nowiki>}}<br />
<br />
The current cursor position can be saved using:<br />
<br />
{{bc|<nowiki>\[\033[s\]</nowiki>}}<br />
<br />
To restore a position, use the following sequence: <br />
<br />
{{bc|<nowiki>\[\033[u\]</nowiki>}}<br />
<br />
The following example uses these sequences to display the time in the upper right corner:<br />
<br />
{{bc|<nowiki>PS1="&gt;\[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\[\033[u\]"</nowiki>}}<br />
<br />
The environment variable ''COLUMNS'' contains the number of columns of the terminal. The above example substracts 4 from its value in order to justify the five character wide output of ''date'' at the right border.<br />
<br />
===Return value visualisation===<br />
<br />
Use this prompt if you want to see the return value of the last executed command.<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[0;32m\];)\"; else echo \"\[\033[0;31m\];(\"; fi)\[\033[00m\] : "</nowiki>}}<br />
<br />
This will give you basic prompt:<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">0 <span style="color: green;">;)</span>&nbsp;: true<br />0 <span style="color: green;">;)</span>&nbsp;: false<br />1 <span style="color: red;">;(</span>&nbsp;:</div><br />
<br />
Zero is a green smiley (replace it with anything you want) and non-zero is a red one. So your prompt will smile if the last operation was successful.<br />
<br />
But you will probably want to use the return value in your own prompt, like this:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">;) andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">;(</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
with a code like this one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\];)\"; else echo \"\[\033[01;31m\];(\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Or, if you want, you can build your prompt using the <span style="color: #0a0; font-weight: bold;">&#10003;</span> unicode symbol for a ''zero'' status and the <span style="color: #a00; font-weight: bold;">&#10007;</span> unicode symbol for a ''nonzero'' status:<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;"><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> true<br /><span style="font-weight: bold;">0</span> <span style="color: #0a0; font-weight: bold;">&#10003; andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> false<br /><span style="font-weight: bold;">1</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> I\ will\ try\ to\ type\ a\ wrong\ command...<br />bash: I will try to type a wrong command...: command not found<br /><span style="font-weight: bold;">127</span> <span style="color: #a00; font-weight: bold;">&#10007;</span> <span style="color: #0a0; font-weight: bold;">andy@alba</span> <span style="color: #55f; font-weight: bold;">~ $</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
starting from a code like this other one:<br />
<br />
{{bc|<nowiki>#return value visualisation<br />
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$\[\033[00m\] "</nowiki>}}<br />
<br />
Here's an alternative that only include the error status if it is nonzero:<br />
{{bc|<nowiki><br />
PROMPT_COMMAND='es=$?; [[ $es -eq 0 ]] &amp;&amp; unset error || error=$(echo -e "\e[1;41m $es \e[40m")'<br />
PS1="${error} ${PS1}"</nowiki>}}<br />
<br />
===Wolfman's===<br />
<br />
After reading through most of the [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html Bash Prompt Howto], the author developed a color bash prompt that displays the last 25 characters of the current working directory. This prompt should work well on terminals with a black background. The following code goes in file {{ic|~/.bashrc}}.<br />
<br />
*Add the bash_prompt_command function. If you have a couple directories with long names or start entering a lot of subdirectories, this function will keep the command prompt from wrapping around the screen by displaying at most the last pwdmaxlen characters from the PWD. This code was taken from the ''Bash Prompt Howto''<nowiki>'s</nowiki> section on [http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x783.html Controlling the Size and Appearance of $PWD] and modified to replace the user's home directory with a tilde.<br />
<br />
{{bc|<nowiki>##################################################<br />
# Fancy PWD display function<br />
##################################################<br />
# The home directory (HOME) is replaced with a ~<br />
# The last pwdmaxlen characters of the PWD are displayed<br />
# Leading partial directory names are striped off<br />
# /home/me/stuff -&gt; ~/stuff if USER=me<br />
# /usr/share/big_dir_name -&gt; ../share/big_dir_name if pwdmaxlen=20<br />
##################################################<br />
<br />
bash_prompt_command() {<br />
# How many characters of the $PWD should be kept<br />
local pwdmaxlen=25<br />
# Indicate that there has been dir truncation<br />
local trunc_symbol=".."<br />
local dir=${PWD##*/}<br />
pwdmaxlen=$(( ( pwdmaxlen &lt; ${#dir} ) ? ${#dir} : pwdmaxlen ))<br />
NEW_PWD=${PWD/#$HOME/\~}<br />
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))<br />
if [ ${pwdoffset} -gt "0" ]<br />
then<br />
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}<br />
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}<br />
fi<br />
}</nowiki>}}<br />
<br />
*The next fragment generates the command prompt and various colors are defined. The user's color for the username, hostname, and prompt ($ or #) is set to cyan, and if the user is root (root's UID is always 0), set the color to red. The command prompt is set to a colored version of Arch's default with the NEW_PWD from the last function.<br />
<br />
:Also, make sure that your color variables are enclosed in double and not single quote marks. Using single quote marks seems to give Bash problems with line wrapping correctly.<br />
<br />
{{bc|<nowiki>bash_prompt() {<br />
case $TERM in<br />
xterm*|rxvt*)<br />
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'<br />
;;<br />
*)<br />
local TITLEBAR=""<br />
;;<br />
esac<br />
local NONE="\[\033[0m\]" # unsets color to term's fg color<br />
<br />
# regular colors<br />
local K="\[\033[0;30m\]" # black<br />
local R="\[\033[0;31m\]" # red<br />
local G="\[\033[0;32m\]" # green<br />
local Y="\[\033[0;33m\]" # yellow<br />
local B="\[\033[0;34m\]" # blue<br />
local M="\[\033[0;35m\]" # magenta<br />
local C="\[\033[0;36m\]" # cyan<br />
local W="\[\033[0;37m\]" # white<br />
<br />
# emphasized (bolded) colors<br />
local EMK="\[\033[1;30m\]"<br />
local EMR="\[\033[1;31m\]"<br />
local EMG="\[\033[1;32m\]"<br />
local EMY="\[\033[1;33m\]"<br />
local EMB="\[\033[1;34m\]"<br />
local EMM="\[\033[1;35m\]"<br />
local EMC="\[\033[1;36m\]"<br />
local EMW="\[\033[1;37m\]"<br />
<br />
# background colors<br />
local BGK="\[\033[40m\]"<br />
local BGR="\[\033[41m\]"<br />
local BGG="\[\033[42m\]"<br />
local BGY="\[\033[43m\]"<br />
local BGB="\[\033[44m\]"<br />
local BGM="\[\033[45m\]"<br />
local BGC="\[\033[46m\]"<br />
local BGW="\[\033[47m\]"<br />
<br />
local UC=$W # user's color<br />
[ $UID -eq "0" ] &amp;&amp; UC=$R # root's color<br />
<br />
PS1="$TITLEBAR ${EMK}[${UC}\u${EMK}@${UC}\h ${EMB}\${NEW_PWD}${EMK}]${UC}\\$ ${NONE}"<br />
# without colors: PS1="[\u@\h \${NEW_PWD}]\\$ "<br />
# extra backslash in front of \$ to make bash colorize the prompt<br />
}</nowiki>}}<br />
<br />
*Finally, append this code. This ensures that the NEW_PWD variable will be updated when you cd somewhere else, and it sets the PS1 variable, which contains the command prompt.<br />
<br />
{{bc|<nowiki>PROMPT_COMMAND=bash_prompt_command<br />
bash_prompt<br />
unset bash_prompt</nowiki>}}<br />
<br />
===KitchM's===<br />
These prompts offer a little more flash and visual clarity. Note that the use of red in the root user's prompt should provide ample warning. That is not to say someone could not use flashing text or arrow to do even more, but these will give you a good starting point.<br />
<br />
'''First''', change the default background in your terminal preferences (this example uses Xfce's Terminal program) to #D2D2D2, and the text color to #000000. The font is listed as DejaVu Sans Mono Book 12. The cursor color is #00AA00, and the tab activity color is #AF0000.<br />
<br />
'''Second''', in ~/.bashrc and right after the PS1= line, enter a new line with the following:<br />
{{bc|<nowiki>PS1='\e[1;33;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;34m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
And then place a # in front of the first PS1 line to remark it out.<br />
<br />
'''Third''', for root user, edit /root/.bashrc in the same manner to include:<br />
{{bc|<nowiki>PS1='\e[1;31;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;31m[dir.= \w] \# &gt; \e[0;0m'</nowiki>}}<br />
Do not forget to comment out the old line.<br />
<br />
These are double-line prompts, and they should look something like these:<br />
<br />
:'''user'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #0000ff; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
:'''root'''<br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bbccdd; font-weight: bold; color: #ff0000; background-color: #d2d2d2;"><span style="color: #ff0000; background: #A9A9A9;">Root</span><span style="color: #00ff00; background: #A9A9A9;"> on myhost</span><span style="color: #ff00ff; background: #A9A9A9;"> Sun Jan 15 12:30 PM</span><br />[dir.= /etc/rc.d] 1 &gt;</div><br />
<br />
You will note that the background colors make them easier to read, and the text colors just keep things interesting. There is a lot of leeway to make them personalized, just with the use of colors. Enjoy!<br />
<br />
==Set window title==<br />
<br />
[[Xterm]] and many other terminal emulators (including PuTTY) allow you to set the window title using special escape sequences. You can define the {{ic|<nowiki>${XTERM_TITLE}</nowiki>}} variable as follows, then insert it at the beginning of the prompt to set [[xterm]] title (if available) to directory@user@hostname:<br />
<br />
{{bc|<nowiki>#set xterm title<br />
case "$TERM" in<br />
xterm | xterm-color)<br />
XTERM_TITLE='\[\e]0;\W@\u@\H\a\]'<br />
;;<br />
esac</nowiki>}}<br />
<br />
The text between {{ic|0;}} and {{ic|\a}} can be set to anything you like, for example:<br />
<br />
{{bc|<nowiki>export PS1="\[\e]0;Welcome to ArchLinux\a\]\$&gt;&gt; "</nowiki>}}<br />
<br />
sets the window title to "Welcome to ArchLinux" and displays this simple prompt: <br />
<br />
<div style="font-family: monospace; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #fff;">$&gt;&gt; <span style="text-decoration: blink;">_</span></div><br />
<br />
==Different colors for text entry and console output==<br />
<br />
If you do not reset the text color at the end of your prompt, both the text you enter and the console text will simply stay in that color. If you want to edit text in a special color but still use the default color for command output, you will need to reset the color after you press enter, but still before any commands get run. You can do this by installing a DEBUG trap in your ~/.bashrc, like this:<br />
<br />
{{bc|<nowiki>trap 'echo -ne "\e[0m"' DEBUG</nowiki>}}<br />
<br />
==Laptop battery status on prompt==<br />
<br />
Read [http://www.basicallytech.com/blog/index.php?/archives/110-Colour-coded-battery-charge-level-and-status-in-your-bash-prompt.html this article] and [https://bbs.archlinux.org/viewtopic.php?pid=1156660#p1156660 this post] for details.<br />
<br />
==See also==<br />
<br />
* [https://aur.archlinux.org/packages.php?ID=18418 gentoo-bashrc] from [[AUR]]<br />
* tput(1)<br />
* [http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html Colours and Cursor Movement With tput]<br />
<br />
==External links==<br />
<br />
* Forum Discussions:<br />
** [https://bbs.archlinux.org/viewtopic.php?id=1817 BASH prompt]<br />
** [https://bbs.archlinux.org/viewtopic.php?id=50885 What's your PS1?]<br />
* http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html<br />
* [http://gilesorr.com/bashprompt/prompts/index.html Giles Orr's collection of sample prompts]</div>JuszR