Bashrc

From ArchWiki
Revision as of 18:58, 26 August 2010 by Spip (Talk | contribs) (i18n)

Jump to: navigation, search

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Bashrc#)

Merge-arrows-2.pngThis article or section is a candidate for merging with Bash.Merge-arrows-2.png

Notes: Talk:Bash (Discuss in Talk:Bashrc#)

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


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی


A place for Arch users' .bashrc file tips and tricks. .bashrc is a configuration file that contains commands to be executed whenever an interactive shell is started.

PS1

To colourise the bash prompt: Comment out the default PS1:

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

The following PS1 is useful for a root bash prompt, with red designation and green console text:

PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\] '

See also this wiki page

Aliases

Default command usage

To make rm prompt for removals

alias rm='rm -i'

to make cp and mv prompt for overwrite

alias cp='cp -i'
alias mv='mv -i'

To make spelling mistakes not matter

alias unmount='umount'
alias pakman='pacman'

Seen in forums to force someone to learn vim

alias nano='vi'

Shortcuts

Useful environment variables

Set a default text editor

EDITOR=nano

or

EDITOR=vi

Add a scripts directory to your path statement

You can add a 'scripts' directory (or any other for that matter) to your path simply by adding the following line

PATH=$PATH:/home/USERNAME/scripts

Modify as needed. Now when you open a new shell window, you can simply type the name of your scripts.

HTTP / FTP Proxy

You can export your HTTP and FTP proxy settings from .bashrc by adding the following:

export http_proxy="http://172.16.1.6:3128"
export ftp_proxy="ftp://172.16.1.6:3128"

Auto complete

It is useful to have auto complete feature(pressing "tab" key 2 times on keyboard) after you type some command like "sudo".
To do this add line in this format to your .bashrc file:

complete -cf your_command

examples:

complete -cf sudo

With this line you can use auto complete feature after command "sudo"

complete -cf man

This will allow you to use auto complete after "man" so you don't have to remember exact name of man page you want to read