If you want to read the latest news from the [http://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:

+

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:

{{bc|<nowiki># fortune is a simple program that displays a pseudorandom message

{{bc|<nowiki># fortune is a simple program that displays a pseudorandom message

# from a database of quotations at logon and/or logout.

# from a database of quotations at logon and/or logout.

Line 329:

Line 331:

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:

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:

See [https://bbs.archlinux.org/viewtopic.php?id=146850 this thread] for details.

See [https://bbs.archlinux.org/viewtopic.php?id=146850 this thread] for details.

Line 335:

Line 337:

==Variations on a theme==

==Variations on a theme==

−

Fere 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:

+

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:

Here is another variation 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 it will appear:

+

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:

A well-established Bash color prompt

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:

I am two with nature. -- Woody Allenandy@alba~ $ lsDesktop Documents Music public.desktopandy@alba~ $ I\ will\ try\ to\ type\ a\ wrong\ command...bash: I will try to type a wrong command...: command not foundandy@alba~:($ echo 'Hello world!'Hello world!andy@alba suPassword:Two can Live as Cheaply as One for Half as Long. -- Howard Kandelalba~ $_

Installation

It's a generalized scheme for all users, so you should start removing your ~/.bashrc file and then modify the /etc/bash.bashrc file and create a /etc/DIR_COLORS file (but ~/.bashrc and /etc/bash.bashrccan 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).

As you can see, a PS1 variable (i.e.: the prompt) is exported. So, if you had previously created a color prompt through the /etc/bash.bashrc file, each user newly created, to see it, should delete the line

PS1='[\u@\h \W]\$ '

from his own ~/.bashrc. Accordingly, if you want to grant to newly created users to have the same colorfull PS1, you should delete that line from /etc/skel/.bashrc.

Example of cohabitation of /etc/bash.bashrc and ~/.bashrc

~/.bashrc and /etc/bash.bashrc can also cohabitate. Here is a possible example of a typical Arch user's ~/.bashrc file which can cohabit with the /etc/bash.bashrc file proposed here, valid for all users. The output will remain coloured.

Random quotations at logon

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 pacman -S fortune-mod to install it, then uncomment the following line from our/etc/bash.bashrc file:

# [[ "$PS1" ]] && /usr/bin/fortune

If you want to colorize (brown in this example) the random message from fortune, replace the previous commented text with:

Tom Gundersen wrote:As systemd 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 initscripts-specific bugs, and may close them as WONTFIX.We therefore strongly encourage all users to migrate to systemd as soon as possible. See the systemd migration guide [https://wiki.archlinux.org/index.php/Systemd].To ease the transition, initscripts support will remain in the official repositories for the time being, unless otherwise stated. As of January 2013, we will start removing initscripts support (e.g., rc scripts) from individual packages without further notice.

Pierre Schmitz wrote:The latest snapshot of our install and rescue media can be found on our Download[https://www.archlinux.org/download/] page. The 2012.11.01 ISO image mainly contains minor bug fixes, cleanups and new packages compared to the previous one:* First media with Linux 3.6*copytoram=n 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.*cowfile_size boot parameter mainly for persistent COW on VFAT. See the README[https://projects.archlinux.org/archiso.git/plain/docs/README.bootparams?id=v4] file for details.

Allan McRae wrote:The number of bugs in the Arch Linux bug tracker is creeping up so it is time for some extermination.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.Join us on the #archlinux-bugs IRC channel. We are spread across timezones, so people should be around all day.

Allan McRae wrote: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.In addition to GNOME, both KDE and XFCE are also affected by this change.

::systemd is now the default on new installations::[https://www.archlinux.org/news/systemd-is-now-the-default-on-new-installations/]

Thomas Bächler wrote:The base group now contains the systemd-sysvcompat package. This means that all new installations will boot with systemd by default.As some packages still lack native systemd units, users can install the initscripts package and use the DAEMONS array in /etc/rc.conf to start services using the legacy rc.d scripts.This change does not affect existing installations. For the time being, the initscripts and sysvinit packages remain available from our repositories. However, individual packages may now start relying on the system being booted with systemd.Please refer to the wiki[https://wiki.archlinux.org/index.php/Systemd] for how to transition an existing installation to systemd.

Pierre Schmitz wrote:The October release of the Arch Linux install medium is available for Download[https://www.archlinux.org/download/] and can be used for new installs or as a rescue system. It contains a set of updated packages and the following notable changes:* systemd is used to boot up the live system.* 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.* EFI boot and setup has been simplified.* gummiboot is used to display a menu on EFI systems.* The following new packages are available on the live system: ethtool, fsarchiver, gummiboot-efi, mc, partclone, partimage, refind-efi, rfkill, sudo, testdisk, wget, xl2tpd

Pierre Schmitz wrote: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 Download[https://www.archlinux.org/download/] and be used for new installs or as a rescue system.In addition to a couple of updated packages and bug fixes the following changes stand out:* First medium with Linux 3.5 (3.5.3)* The script boot parameter works again (FS#31022[https://bugs.archlinux.org/task/31022])* When booting via PXE and NFS or NBD the ISO will be copied to RAM to ensure a more stable usage.* The live medium contains usb_modeswitch and wvdial which e.g. allows to establish a network connection using an UMTS USB dongle* Furthermore the newest versions of initscripts, systemd and netcfg are included.

Pierre Schmitz wrote:The August snapshot of our live and install media comes with updated packages and the following changes on top of the previous ISO image[/news/install-media-20120715-released/]:* GRUB 2.0 instead of the legacy 0.9 version is available.* The Installation Guide[https://wiki.archlinux.org/index.php/Installation_Guide] can be found at /root/install.txt.* ZSH with Grml's configuration[http://grml.org/zsh/] 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.* The network daemon is started by default which will automatically setup your network if DHCP is available.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 download page[/download/]. The next snapshot is scheduled for September.

Variations on a theme

Here are some PS1 variables (i.e.: prompts) with different layout to be applyied to our/etc/bash.bashrc file. When you choose a layout you must replace the following lines from our/etc/bash.bashrc file:

From Arch Forum #1

I am two with nature. -- Woody Allen┌─[andy@alba]─[~]└──╼ lsDesktop Documents Music public.desktop┌─[andy@alba]─[~]└──╼ I\ will\ try\ to\ type\ a\ wrong\ command...bash: I will try to type a wrong command...: command not found┌─[✗]─[andy@alba]─[~]└──╼ echo 'Hello world!' Hello world!┌─[andy@alba]─[~]└──╼ suPassword:Two can Live as Cheaply as One for Half as Long. -- Howard Kandel┌─[alba]─[~]└──╼_

Note:Some unicode symbols (like ✗ 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, here you have a little plain text converter.

And finally here is the PS1 variable for this effect to be applyied to our/etc/bash.bashrc file (see above):

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, here you have a little plain text converter.

And finally here is the PS1 variable for this effect to be applyied to our/etc/bash.bashrc file (see above):

Restoring the original /etc/bash.bashrc file

If you repent having modified the /etc/bash.bashrc file, you can always restore the original Arch /etc/bash.bashrc file from the bash package and remove the /etc/DIR_COLORS file. Note that there is not an "official" bash.bashrc: each distribution has its own.

Original /etc/bash.bashrc from Gentoo

The original not modified Gentoo's /etc/bash.bashrc file can be found here.

Step by step

If you want to create a style all your own, you can take a look at these tips. This Forum thread could give you more informations and examples.

Basic prompts

The following settings are useful for distinguishing the root prompt from non-root users.

Edit Bash's personal configuration file:

$ nano ~/.bashrc

Comment out the default prompt:

# PS1='[\u@\h \W]\$ '

Add the following green prompt for regular users:

[chiri@zetsubou ~]$_

PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '

Edit root's .bashrc file; copy it from /etc/skel if the file is not present:

\u - Username. The original prompt also has \h, which prints the host name.

\w - Current absolute path. Use \W for current relative path.

\$ - The prompt character (eg. '#' for root, '$' for regular users).

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.

Advanced prompts

Load/Mem Status for 256colors

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.

This prompt is from AskApache.com's 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.

This is for 256 color terminals, which is where the \033[38;5;22m terminal escapes come from.

To use in a prompt (note double quotes to enable $color variable expansion and \[ \] escapes around them so they are not counted as character positions and the cursor position is not wrong):

PS1="\[$txtblu\]foo\[$txtred\] bar\[$txtrst\] baz : "

If you experience premature line wrapping when entering commands at the prompt then missing escapes is most likely to be the reason.

Prompt escapes

The various Bash prompt escapes listed in the manpage:

Bash allows these prompt strings to be customized by inserting a
number of ''backslash-escaped special characters'' that are
decoded as follows:
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format} the format is passed to strftime(3) and the result
is inserted into the prompt string an empty format
results in a locale-specific time representation.
The braces are required
\e an ASCII escape character (033)
\h the hostname up to the first `.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the portion following
the final slash)
\t the current time in 24-hour HH:MM:SS format
\T the current time in 12-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user
\v the version of bash (e.g., 2.00)
\V the release of bash, version + patch level (e.g., 2.00.0)
\w the current working directory, with $HOME abbreviated with a tilde
\W the basename of the current working directory, with $HOME
abbreviated with a tilde
\! the history number of this command
\# the command number of this command
\$ if the effective UID is 0, a #, otherwise a $
\nnn the character corresponding to the octal number nnn
\\ a backslash
\[ begin a sequence of non-printing characters, which could be used
to embed a terminal control sequence into the prompt
\] end a sequence of non-printing characters
The command number and the history number are usually different:
the history number of a command is its position in the history
list, which may include commands restored from the history file
(see HISTORY below), while the command number is the position in
the sequence of commands executed during the current shell session.
After the string is decoded, it is expanded via parameter
expansion, command substitution, arithmetic expansion, and quote
removal, subject to the value of the promptvars shell option (see
the description of the shopt command under SHELL BUILTIN COMMANDS
below).

Positioning the cursor

The following sequence sets the cursor position:

\[\033[<row>;<column>f\]

The current cursor position can be saved using:

\[\033[s\]

To restore a position, use the following sequence:

\[\033[u\]

The following example uses these sequences to display the time in the upper right corner:

PS1=">\[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\[\033[u\]"

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.

Return value visualisation

Use this prompt if you want to see the return value of the last executed command.

Wolfman's

After reading through most of the 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 ~/.bashrc.

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's section on Controlling the Size and Appearance of $PWD and modified to replace the user's home directory with a tilde.

##################################################
# Fancy PWD display function
##################################################
# The home directory (HOME) is replaced with a ~
# The last pwdmaxlen characters of the PWD are displayed
# Leading partial directory names are striped off
# /home/me/stuff -> ~/stuff if USER=me
# /usr/share/big_dir_name -> ../share/big_dir_name if pwdmaxlen=20
##################################################
bash_prompt_command() {
# How many characters of the $PWD should be kept
local pwdmaxlen=25
# Indicate that there has been dir truncation
local trunc_symbol=".."
local dir=${PWD##*/}
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
NEW_PWD=${PWD/#$HOME/\~}
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
if [ ${pwdoffset} -gt "0" ]
then
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
fi
}

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.

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.

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.

PROMPT_COMMAND=bash_prompt_command
bash_prompt
unset bash_prompt

KitchM's

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.

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.

Second, in ~/.bashrc and right after the PS1= line, enter a new line with the following:

These are double-line prompts, and they should look something like these:

user

Root on myhost Sun Jan 15 12:30 PM[dir.= /etc/rc.d] 1 >

root

Root on myhost Sun Jan 15 12:30 PM[dir.= /etc/rc.d] 1 >

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!

Set window title

Xterm and many other terminal emulators (including PuTTY) allow you to set the window title using special escape sequences. You can define the ${XTERM_TITLE} variable as follows, then insert it at the beginning of the prompt to set xterm title (if available) to directory@user@hostname:

The text between 0; and \a can be set to anything you like, for example:

export PS1="\[\e]0;Welcome to ArchLinux\a\]\$>> "

sets the window title to "Welcome to ArchLinux" and displays this simple prompt:

$>> _

Different colors for text entry and console output

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: