Bashrc

From ArchWiki

Jump to: navigation, search
Image:Tango-document-new.png This article is a stub.
This typically means the article is a placeholder for more content to come. Knowledgeable users are encouraged to help expand the article.
Image:Tango-two-arrows.png This article is a candidate for merging.
It is suggested that this page or section be merged with Bash. (Discuss)
i18n
English
Español
Nederlands

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

Contents

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"
Personal tools