Skip to main content

Questions tagged [bashrc]

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

Filter by
Sorted by
Tagged with
568 votes
6 answers
209k views

Difference between .bashrc and .bash_profile

What's the difference between .bashrc and .bash_profile and which one should I use?
cfischer's user avatar
  • 9,093
236 votes
3 answers
98k views

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

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 ...
Ian Mackinnon's user avatar
150 votes
4 answers
254k views

Bash if on single line

I would like to know how can I write if conditions inside a bash script on a single line. For example, how can I write this on a single line, and then put another one just like it on the next? if [ -...
Horațiu Mlendea's user avatar
139 votes
8 answers
186k 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 ...
agentofuser's user avatar
  • 7,437
121 votes
6 answers
303k 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?
Brian's user avatar
  • 1,431
117 votes
3 answers
384k 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?
pineapple's user avatar
  • 2,054
111 votes
8 answers
119k 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?
William Jockusch's user avatar
99 votes
11 answers
106k 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?
user avatar
67 votes
3 answers
85k 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 ...
Damon's user avatar
  • 2,769
51 votes
7 answers
145k 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....
mbb's user avatar
  • 2,546
49 votes
3 answers
75k 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 ...
Viriato's user avatar
  • 613
48 votes
7 answers
58k 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 ...
KurToMe's user avatar
  • 483
40 votes
2 answers
12k 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 ...
Abonec's user avatar
  • 502
37 votes
2 answers
119k 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 ...
medihack's user avatar
  • 920
29 votes
2 answers
75k 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 ...
sa125's user avatar
  • 1,006
27 votes
3 answers
18k 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 ...
Alan W. Smith's user avatar
24 votes
6 answers
221k 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. ...
detraveller's user avatar
24 votes
10 answers
68k views

Why are alias names defined in .bashrc file are not working as expected?

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=/...
Venkatesh's user avatar
  • 341
23 votes
4 answers
36k 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 ...
dgo.a's user avatar
  • 881
22 votes
1 answer
12k views

Bash is slow to start because of this line in .bashrc. What could cause this?

My .bashrc file contains a line to this effect: alias prog="/path/to/script.sh $(find $(pwd) -name prog)" When I comment out this line, Bash starts almost instantly when I open a new terminal. With ...
BBales's user avatar
  • 323
20 votes
3 answers
22k 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?
cfischer's user avatar
  • 9,093
19 votes
2 answers
9k 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 ...
marcusw's user avatar
  • 1,768
18 votes
1 answer
11k 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 my ...
acm's user avatar
  • 283
18 votes
6 answers
19k 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?...
marvin2k's user avatar
  • 281
17 votes
4 answers
6k 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 ...
user75250's user avatar
  • 287
17 votes
5 answers
8k views

Bash prompt to change color when I am logged into a server

Is there a way to make the bash prompt dynamic, so that it changes color when logged into a server? So I want the like the color to be green when on my system and change to red when connected to ...
nitin's user avatar
  • 335
16 votes
3 answers
39k 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 ...
fragsworth's user avatar
15 votes
5 answers
24k views

Putty solarized the manual way

I would like to use the solarized color scheme in PuTTY. The tricky part is I don't have administrator privileges in this machine. So I will have to manually change the default colors through Change ...
dmvianna's user avatar
  • 303
13 votes
4 answers
11k 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 ...
Car981's user avatar
  • 395
13 votes
3 answers
2k 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 ...
Spade's user avatar
  • 233
13 votes
3 answers
10k views

`ssh <host>` is a login shell, but `ssh <host> <command>` is not?

I've noticed that when I run a command directly on an SSH host using the ssh <host> <command> syntax, I see the output of .bashrc but not the output of .bash_profile (or .profile). For ...
Ryan Lue's user avatar
  • 505
12 votes
1 answer
14k 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 ...
Vladimir's user avatar
  • 285
12 votes
4 answers
14k 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 ...
Rafael T's user avatar
  • 254
12 votes
4 answers
2k 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 ...
Daniel Huckstep's user avatar
11 votes
2 answers
7k views

bash: source from URL

In addition to my own computer, I sometimes use an Ubuntu cluster at my school. Rather than manually keep my .bashrc's in sync, I would like to make the school cluster's .bashrc source my personal ....
AlcubierreDrive's user avatar
10 votes
6 answers
6k 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 ...
Ryan's user avatar
  • 203
10 votes
2 answers
7k views

How to escape commands in a bashrc alias?

I need to occasionally touch a file with the current timestamp as the filename. I would do so this way: touch `date "+%Y-%m-%d_%H-%M"`.txt However, I'd like to define an alias for this. When I try ...
GJ.'s user avatar
  • 9,883
10 votes
1 answer
3k 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 ...
Nicolai Fröhlich's user avatar
9 votes
3 answers
15k 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 ...
ivan's user avatar
  • 1,075
9 votes
5 answers
11k views

How do I stop automatic changing of iterm tab titles?

After switching to using .bashrc instead of .bash_profile (I didn't like how the default terminal worked with one config file and utilities like screen with another), the behavior of iterm2 changed. ...
executor21's user avatar
9 votes
3 answers
16k 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 ...
gsgx's user avatar
  • 1,033
9 votes
2 answers
7k views

Which bash rc files are run on non-interactive/non-login shells?

My Understanding there are no rc files called for non-interactive/non-login shells; for example, those run by cron (I don't know this for certain and would lean on the community's expertise) non-...
vol7ron's user avatar
  • 485
9 votes
2 answers
21k views

How does one define aliases for use within MobaXTerm *local* bash shell?

I have been using MobaXterm for the last couple of weeks in Windows and I love it. However, I haven't quite figured out how to define my own aliases for use within the local bash shell. The obvious ...
Mateo's user avatar
  • 191
8 votes
1 answer
2k views

Does .bashrc contain syntax errors?

In the Ubuntu 18.04 LT .bashrc file there is the following: # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color) color_prompt=yes;; esac Isn't xterm-...
Argent's user avatar
  • 285
8 votes
5 answers
2k views

Restoring ~/.bashrc without using bash commands

I think I had a typo when I add a path to ~/.bashrc and after I source it, I cannot use bash commands anymore. Now I want to restore a normal ~/.bashrc, however most of the discussion I found (e.g. ...
Johnny Tam's user avatar
8 votes
2 answers
784 views

Can I make bash stop parsing and validating a certain alias?

I'm using Fedora 25, and have added the following alias to my bash profile: alias releasenotes="dnf updateinfo --refresh info `dnf check-update | cut -d '.' -f 1 | xargs` | less" (I can't use ...
iLikeDirt's user avatar
  • 333
8 votes
4 answers
17k 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?
user avatar
8 votes
3 answers
48k 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: /...
grerdas's user avatar
  • 81
8 votes
3 answers
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: ...
crayment's user avatar
  • 171
7 votes
2 answers
11k 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 ...
Radek's user avatar
  • 3,104

1
2 3 4 5 6