.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)

153
votes
3answers
43k views

Difference between .bashrc and .bash_profile

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

What is the .bashrc file?

Unix shells when starting read the .bashrc file and execute commands contained in them. What is this file and what do they execute?
25
votes
2answers
6k views

Is there windows equivalent of 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?
24
votes
5answers
18k 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?
21
votes
3answers
4k 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 ...
17
votes
1answer
24k 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 ...
13
votes
2answers
14k 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 ...
12
votes
3answers
723 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 ...
9
votes
3answers
7k 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?
9
votes
2answers
13k 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 ...
9
votes
3answers
2k 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 ...
9
votes
2answers
6k 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 ...
8
votes
5answers
2k 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
2answers
11k 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 ...
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
3answers
2k 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 ...
7
votes
4answers
16k 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 & ...
7
votes
2answers
2k 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 ...
7
votes
0answers
389 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
2answers
6k 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 ...
6
votes
2answers
5k 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?
6
votes
1answer
537 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?
6
votes
4answers
2k 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?
5
votes
4answers
561 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 ...
4
votes
2answers
2k 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 ...
4
votes
1answer
301 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
34k 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: ...
4
votes
4answers
3k 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
2answers
979 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 ...
4
votes
1answer
573 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
1k 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
536 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
2answers
172 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
7answers
1k 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 ...
3
votes
3answers
213 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 ...
3
votes
2answers
113 views

Append dir to PATH

I'm trying to localy add a dir to the global $PATH variable. I added the following to my .bashrc. export PATH=$PATH:$VRS/bin But PATH seems to get concatenated to itself over & over every time ...
3
votes
2answers
474 views

gnome-terminal: how to preserve symlinks of working directory when opening new tab?

If I'm using gnome-terminal in a working directory whose path includes symlinks and I open a new tab, the symlinks will be expanded to their destinations in the working directory of the new tab. Is ...
3
votes
2answers
4k views

How can I change my bash prompt on Ubuntu?

I have one account on an Ubuntu server with the correct PS1 variable and I want to make one of my other accounts on the same server have the same PS1 variable, so that my prompt on this new account ...
3
votes
1answer
1k 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 ...
3
votes
2answers
3k 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 ...
3
votes
1answer
699 views

~/.bashrc not sourced in a new lxterminal window

I added some lines to my ~/.bashrc like export JAVA_HOME=/opt/jdk1.6.0_22 I sourced it: $ source ~/.bashrc $ env | grep 'JAVA' JAVA_HOME=/opt/jdk1.6.0_22 Then I created a basic bash script under ...
3
votes
1answer
132 views

What site is there for sharing Linux custom configuration files?

I remember someone here at SU gave a link to a site where you could share your Linux custom configuration files (like bashrc, vimrc and others), but I don't remember what was that site. I already ...
3
votes
1answer
139 views

How to benchmark bashrc / zshrc and prompt rendering time?

As im currently experimenting with new stuff in my prompt i need a way to tell what the performance impact is. How can i monitor how long it takes to render my prompt and the time it takes to source ...
3
votes
1answer
658 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 ...
3
votes
3answers
62 views

Use different colors for every another grep

How can I configure grep that I could highlight in color smarter? By using different colors? Problem : "grep --color" default use red to highlight matches, but it still difficult to read for ...
3
votes
4answers
2k 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 ...
3
votes
2answers
93 views

Source my bash profile when I su on OS X

I'd like to source my .bash_profile (or maybe some other file) whenever I switch to superuser. (.bash_profile is the login rc on Mac OS X, .bashrc is the non-login script, and .profile is a login rc ...
2
votes
3answers
707 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 ...
2
votes
2answers
1k views

Sudo can not find binary

I have a problem. Lately I've installed nodejs (if you don't know what it is, it does not really matter, could be anything else) from sources to /opt/node: $ ls -la /opt ... lrwxrwxrwx 1 root root ...
2
votes
2answers
179 views

Why is there a dot in front of .bashrc

I have been trying to figure this out for a while now, pretty simple question for some I can only guess, but why is there a 'dot' in front of .bashrc?