.bashrc is one of the scripts the Bash shell reads and executes when started as an interactive (but not login) shell.

learn more… | top users | synonyms (1)

302
votes
3answers
90k views

Difference between .bashrc and .bash_profile

What's the difference between .bashrc and .bash_profile and which one should I use?
70
votes
4answers
240k views

What is the .bashrc file?

Unix shells when starting read the .bashrc file and execute commands written in it. What is this file and what does it execute?
58
votes
3answers
12k views

What does the 'rc' in `.bashrc`, etc. mean?

Well, this is embarrassing. I feel like I just realised I don't know a loyal colleague's name after working with them for 10 years. "Hey, er... *cough!*, thanks for that great job you did on setting ...
39
votes
5answers
33k views

Mac OS X .bashrc not working

I have a one-line .bashrc file in my home directory: alias countlines='find . -type f -print0 | xargs -0 cat | wc -l' But it is not creating the alias. Why might that be?
38
votes
6answers
14k views

Is there windows equivalent to the .bashrc file in linux?

Just discovered doskey emacs=emacs -nw $*, but without something like .bashrc, I'll have to type that every time I start a shell, right?
37
votes
2answers
43k views

Show only current directory name (not full path) on bash prompt

The way my bash prompt is currently configured, it shows the whole path to the current directory. This is annoying when I'm deep inside a directory tree, as the prompt becomes so long that every ...
36
votes
2answers
43k views

How do I modify my git bash profile in Windows?

I'm using Git Bash on Windows 7 and would like to set up bash profile aliases such as alias gs='git status' to make my life easier. How can I do this?
22
votes
5answers
17k views

MinGW Bash profile

I use MinGW on windows 7. I have a .bashrc with some aliases in it. The file is in my home folder which is where MinGW starts me in, so it also believes that the folder is my home folder. It does not ...
20
votes
3answers
26k views

Environment variables in bash_profile or bashrc?

I have found this question [blog]: Difference between .bashrc and .bash_profile very useful but after seeing the most voted answer (very good by the way) I have further questions. Towards the end of ...
19
votes
2answers
39k views

Open gnome terminal programmatically and execute commands after bashrc was executed

For starting my dev environment I wrote a little script. One part is to open a gnome terminal with several tabs where automatically some commands should be executed. Some of those commands depend on ...
16
votes
3answers
7k views

Is it possible to override the command line's built in “cd” command?

Just about every time I 'cd' to a different directory on my machine (in this case, running Mac OS X 10.6.7) via the command line (which is bash), I immediately type 'ls' to get the list of contents in ...
16
votes
2answers
5k views

Linux: coloring bash prompt will break carriage return

When I try to colorize the bash prompt like this: export PS1="\e[0;31m[\u@\h \W]\$ \e[m " it breaks the carriage return (instead of going to a new line when line is full, it starts in the same line ...
15
votes
3answers
14k views

What's the difference between /etc/bash.bashrc and ~/.bashrc? Which one should I use?

When should I use each of the two .bashrc files to set my aliases, prompt, etc?
15
votes
5answers
41k views

Where's .bashrc for root?

I know it's not best practice, but on my dev system I login as root. What's the equivalent of the .bashrc file so I can alias some functions? I've found the /etc/bash.bashrc & /etc/bash.bashrc....
14
votes
4answers
3k views

Bash completion makes bash start slowly

Starting a bash on my ubuntu system takes about 2 seconds. If I remove loading /etc/bash_completition in .bashrc it starts without delay. Of course I don't want to give up completition and I don't ...
13
votes
2answers
4k views

Is it a good idea to put “screen -r” in my .bashrc?

I'd like to use screen to keep ssh sessions alive on my server. It would be nice if I could automatically resume any running session for my user when I log in. The straightforward way to do this would ...
12
votes
3answers
1k views

What does . .bashrc actually do?

When I enter a eg. a new alias into my .bashrc file I can't use it in that terminal window immediately and until recently I thought I had to restart the terminal to reload the .bashrc file. Then I ...
10
votes
2answers
23k views

Bash not loading '.profile' in new session on Linux

I'm setting up a new Linux machine I got from our IT dept, and noticed .profile is not loaded when I start a new terminal session. The current shell is Bash, though I changed it from the default sh it ...
10
votes
5answers
5k views

bash: execute command given in commandline and don't exit

how do I specifiy a command on the commmandline of bash which shall be executed once inside the new bash after reading ~/.bashrc -- But all this without letting bash exit after the command is finished?...
9
votes
6answers
4k views

bashrc: how to know X window is available or not?

There is a part in my ~/.bashrc, which sets $EDITOR to be gvim. It works fine when I am in X window. However, if I ssh to my workstation (from another workstation) gvim starts to complain "cannot open ...
8
votes
1answer
6k views

iTerm/zsh not reading .bashrc OR .bash_profile

In ~/.bash_profile I have : if [ -f ~/.bashrc ]; then source ~/.bashrc fi In ~/.bashrc I have some aliases When I load a new iTerm window, my aliases do not work. If I source ~/.bashrc they ...
8
votes
3answers
2k views

Adding git branch to bash prompt on snow leopard

I am using this: $(__git_ps1 '(%s)') It works however it does not update when I change directories or checkout a new branch. I also have this alias: alias reload='. ~/.bash_profile' Sample run: ...
7
votes
2answers
10k views

running .bashrc versus new login

I added new alias into .bashrc Running .bashrc doesn't create that alias but new log in yes. Could you somebody explain why is that so and how I can test if the new .bashrc works without doing test ...
7
votes
1answer
3k views

.bashrc loading aliases from different file

I have a .bashrc file, which I want to setup so it reads aliases from an .aliases file and sets them up. Currently I have: # User specific aliases and functions while read alias_line do echo ...
7
votes
1answer
1k views

Bash Alias Adding a Background Process

In my .bashrc, I want to put something like this. alias lst='ls &' So that I can do something like this. $ lst /tmp which will be translated into $ ls /tmp & How can I do the above?
7
votes
0answers
391 views

What's the meaning of “rc” in filenames such as .vimrc and .bashrc? [duplicate]

There are many file with a name containing "rc", but what's the meaning of "rc"?
6
votes
3answers
40k views

How to execute python script from console without writing full path?

I have a few python scripts on /usr/share/scripts/ that I use often, and I want to be able to execute them by just writing the name and not the full path, how could I do this? echo $PATH shows me: /...
6
votes
4answers
3k views

How do I permanently set my bashrc changes?

Everytime I log into SSH, I have to manually source the bashrc file to set my path variables the way I want to. How do I have bash do it automatically? Shouldn't it be automatic?
6
votes
3answers
8k views

Cygwin .bashrc not being source because cygwin starting in Windows home

NOTE: Please see my second edit below for an update on the problem. Cygwin was working fine for me until last week. Now .bashrc isn't getting sourced. I must have installed something or changed ...
6
votes
1answer
3k views

overriding user defined functions with the same name as system commands

This function exists in one of my users' ~/.bashrc: function rm() { ls $* echo "rm?" read ans if [ "$ans" == 'y' ]; then /bin/rm $* fi } In ...
5
votes
3answers
3k views

Why do people source bash_profile from bashrc instead of the other way round?

It sounds like most terminal emulators don't run local sessions as login by default, so they'll load bashrc rather than bash_profile. So why do most people put everything in bash_profile and have ...
5
votes
2answers
4k views

How to persist bash history?

I don't know if this is expected, but my history is not saved across sessions. This is to say, if I close the window, then when I open it again, the history is empty. How can I persist it across ...
5
votes
4answers
751 views

Run parts of .bashrc asynchronously

I have some exports and other things that require another program to run (to get paths or whatever) and they take a non-trivial amount of time to run, meaning my bash startup time is on the order of 5 ...
5
votes
1answer
107 views

Execute same command for each non-interactive bash session

I need to implement some config - I need to execute some code, if someone on my system calls for bash command in any form (interactive, non-interactive and bash -c form). For example this is command I ...
5
votes
1answer
4k views

Bash, how to globally fix ^H and ^? backspace problems

I'd like to fix this frequent problem where the shell on a remote server thinks my terminal's backspace key is ^? and sometimes it thinks it is ^H, and happens to be incorrect and outputs the wrong ...
4
votes
5answers
24k views

No bashrc file in my home directory

Here is what I noted down from my lecture: Find file .bashrc in your home directory do vi .bashrc When you put an application folder somewhere, make sure that its address is in the path variable. ...
4
votes
4answers
6k views

why alias names defined in .bashrc file are not working?

I have give alias names in .bashrc file like below. But the alias names are not working. why? alias c='clear' alias l='ls -lt' alias h='history' alias d='ls -lt |grep "^d"' export ORACLE_HOME=/...
4
votes
7answers
2k views

Bash prompt: how to have the initials of directory path

I normally have just the name of the current directory in my bash prompt (PS1='\u@\h:\W$ '), so if I am in ~/projects/superapp/src/ I get: hamish@host:src$ However I'd like to have an indication ...
4
votes
3answers
6k views

“Reset” colors of terminal after ssh exit/logout

When I ssh into a remote server, I like the colors of the terminal to change. I use setterm on my remote ~/.bashrc file to get this done. However, when I exit, the terminal colors are not reset to the ...
4
votes
2answers
5k views

Spaces in Linux environmental variables?

Given directory: /media/foo/can haz/bar, I have tried editing bash.rc with: export Foo=/media/foo/can haz/bar export Foo=/media/foo/can\ haz/bar export Foo='/media/foo/can haz/bar' export Foo="/media/...
4
votes
1answer
689 views

BASH function not escaping control characters

Hey guys I have a function that I'm using to find stuff, but unfortunately anytime I pass it a control character ($intVal or testing : etc) it chokes. I was wondering what the fix was? I can ...
4
votes
3answers
2k views

Source new .bashrc in all open terminals

I find myself having many terminals open at once all the time. When I update my .bashrc, I have to go to each terminal and execute . .bashrc to source the terminal with the new .bashrc. This is ...
4
votes
4answers
6k views

How do I only display the base dir in my Ubuntu Terminal?

In Ubuntu 10.04 Terminal when I traverse into some long directory structure the entire path gets displayed, this leads to lot of space wastage on my terminal, where the cursor comes way over to the ...
4
votes
1answer
930 views

Bash shell: how to reconcile portable configuration files and GUI terminal start-up types (login or interactive)?

In an attempt to "properly" implement a standard configuration of my preferred shell, bash, for use across multiple platforms, I've come across some confusion when dealing with terminals that are ...
4
votes
2answers
2k views

To have Vim Psql's editor

I have a Fresh Ubuntu installation. I have no personal dot-files active. I run unsuccessfully \e file.sql in Psql, when I have the following in my .bashrc, since Nano opens instead of Vim export ...
4
votes
3answers
50 views

Periodically source shell profile

I'm a zsh user, but this should apply to any shell in theory. When I edit my .zshrc to add a new alias, I have to source ~/.zshrc in all of my open terminal tabs/windows to be able to use the new ...
4
votes
3answers
2k views

Find out where $PATH is defined

I recently installed an Arch-Linux System. If I type echo $PATH it points (among others) to a directory inside my /home/user/dir I can remember I set up somewhere. I have it as root user also, so ...
4
votes
1answer
885 views

Problems with bash path when using 'su'

In Ubuntu Lucid Lynx, I'm trying to do su -l user -c "foo.sh args" where foo.sh is an executable bash script on the PATH set in ~user/.bashrc. Unfortunately, this fails because it can't find foo....
4
votes
2answers
209 views

How to create a directory symbol like ~ for HOME?

I've got a directory path for which I want to create a shortcut, like ~ for a users home directory. I've tried the ENV variables, and I could match $<something> for a path, but I dont want ...
3
votes
2answers
2k views

xterm not wrapping text properly

I'm configuring both my gnome-terminal and xterm columns (i still haven't picked which of these I will be using) and I have a couple of issues I would like to fix: the typing area seems to be ...