{{note|[[Bash]] users should make sure extglob is enabled: {{codeline|shopt -s extglob}}. It is enabled by default if using [[Bash#Advanced completion|Bash completion]]. [[Zsh]] users should do: {{codeline|setopt kshglob}} instead.}}

+

{{note|[[Bash]] users should make sure extglob is enabled: {{codeline|shopt -s extglob}}, for example by adding it to the {{Filename|.bashrc}}. It is enabled by default if using [[Bash#Advanced completion|Bash completion]]. [[Zsh]] users should do: {{codeline|setopt kshglob}} instead.}}

Another way to do this is to install ''unp'' package.

Another way to do this is to install ''unp'' package.

Revision as of 23:26, 16 October 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Legacy mode

If Bash is invoked with the name Template:Codeline, it tries to mimic the startup behavior of historical versions of Template:Codeline as closely as possible, while conforming to the posix standard as well.

In this mode, bash sources the startup files and then enters POSIX compliance.

Configuration

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason:please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Bash#)

/etc/profile

Template:Filename is sourced by all Bourne-compatible shells upon login. It sets up an environment upon login and loads application-specific (Template:Filename) settings.

.profile

This file is read and sourced by bash when an interactive login shell is started.

.bashrc

The file Template:Filename is read and sourced by bash when a non-login interactive shell is started, for example, when you open a virtual console from the desktop environment. This file is useful for setting up a user-specific shell environment.

Shell and environment variables

The behavior of bash and programs run by it can be influenced by a number of environment variable. Environment variables are used to store useful values such as command search directories, or which browser to use. When a new shell or script is launched it inherits its parent's variables, thus starting with an internal set of shell variables[1].

These shell variables in bash can be exported in order to become environment variables:

Command line

Bash command line is managed by the separate library called Readline. Readline provides a lot of shortcuts for interacting with the command line i.e. moving back and forth on the word basis, deleting words etc. It is also Readline's responsibility to manage history of input commands. Last, but not least, it allows you to create macros.

Aliases

alias is a command, which enables a replacement of a word with another string. It is often used for abbreviating a system command, or for adding default arguments to a regularly used command.

Advanced completion

Despite Bash's native support for basic file name, command, and variable auto-completion, there are ways of improving and extending its reach.

The Template:Package Official package extends functionality by adding auto-completion to a wide range of commands and their options. Enabling advanced bash completion is quite simple, just install the following package:

Faster completion

it is no longer necessary to hit Template:Keypress (default binding) twice to produce a list of all possible completions (both when a partial completion is possible and when no completion is possible), as a single key-press will suffice. Alternatively, to produce such a list only when no completion is possible (i.e., not when a partial completion is possible), append the following command in lieu of the previous one:

Clear the screen after logging out

To clear the screen after logging out on a virtual terminal, append the following lines to Template:Filename:

clear
reset

ASCII art, fortunes and cowsay

Along with a colors, system info and ASCII symbols, Bash can be made to display a piece of ASCII art on login. ASCII images can be found online and pasted into a text file, or generated from scratch. To set the image to display in a terminal on login, place the string

Note: By default, Template:Codeline displays quotes and phrases that are rather inoccuous. However, the package does contain a set of comments some will find offensive, located in Template:Filename. See the man page for more info on these.

The ASCII images are generated by Template:Filename text files located in Template:Filename, and all themes can be listed with the command Template:Codeline These files can be edited to the user's liking; custom images can also be created from scratch or found on the net. The easiest way create a custom cow file from an image found online would be to open an existing Template:Filename file in a text editor, copy-and-paste the image from a browser and save the file as a different name. Test the custom file using