by Josh Staiger
Explains how to configure Apple Mac OS X (macOS Unix) Terminal to have colorful ls command output for bash shell permanently. $ source /.bashrc Test it: $ ls $ ll.
WHEN working with Linux, Unix, and Mac OS X, I always forget which bash config file to edit when I want to set my PATH and other environmental variables for my shell. Should you edit .bash_profile or .bashrc in your home directory?
You can put configurations in either file, and you can create either if it doesn’t exist. But why two different files? What is the difference?
According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.
You can put configurations in either file, and you can create either if it doesn’t exist. But why two different files? What is the difference?
According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.
When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt.
But, if you’ve already logged into your machine and open a new terminal window (xterm) inside Gnome or KDE, then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.
But, if you’ve already logged into your machine and open a new terminal window (xterm) inside Gnome or KDE, then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.
Say, you’d like to print some lengthy diagnostic information about your machine each time you login (load average, memory usage, current users, etc). You only want to see it on login, so you only want to place this in your .bash_profile. If you put it in your .bashrc, you’d see it every time you open a new terminal window.
An exception to the terminal window guidelines is Mac OS X’s Terminal.app, which runs a login shell by default for each new terminal window, calling .bash_profile instead of .bashrc. Other GUI terminal emulators may do the same, but most tend not to.
- On Mac OS X Yosemite, run the following command: vi /.profile Then add the following line: source /.bashrc Now save and close.profile, then open a new Terminal window or just run: source /.profile See also this answer. It worked on v10.10.3.
- I am using iTerm in Mac OS X 10.6. It seems when I open iTerm, neither.bashrc nor.bashprofile is sourced. I can tell because the aliases defined in.bashrc are not set.
![Bashrc For Mac Os X Bashrc For Mac Os X](/uploads/1/1/7/8/117804673/295076694.png)
Most of the time you don’t want to maintain two separate config files for login and non-login shells — when you set a PATH, you want it to apply to both. You can fix this by sourcing .bashrc from your .bash_profile file, then putting PATH and common settings in .bashrc.
To do this, add the following lines to .bash_profile:
Now when you login to your machine from a console .bashrc will be called.
I've spent years curating a collection of Mac bash aliases and shortcuts to make my life easier. My full .bash_profile is below, feel free to take whatever you find useful and put it to good use.
A (very) quick primer on .bash_profile for Mac Users
![.bashrc file on mac os x .bashrc file on mac os x](/uploads/1/1/7/8/117804673/780914051.png)
There is a hidden file in your Mac’s user directory named .bash_profile. This file is loaded before Terminal loads your shell environment and contains all the startup configuration and preferences for your command line interface. Within it you can change your terminal prompt, change the colors of text, add aliases to functions you use all the time, and so much more.
This file is often called a ‘dot file’ because the ‘.’ at the beginning of it’s name makes it invisible in the Mac Finder. You can view all invisible files in the Terminal by typing
ls -al
in any directory.How to edit your .bash_profile
For the newly initiated, here’s how you can edit the .bash_profile on your Mac. Set up wifi on mac.
Step 1: Fire up Terminal.app
Bashrc For Mac Os X64
Step 2: Type
nano .bash_profile
– This command will open the .bash_profile document (or create it if it doesn’t already exist) in the easiest to use text editor in Terminal – Nano.Step 3: Now you can make a simple change to the file. Paste these lines of code to change your Terminal prompt.
Step 4: Now save your changes by typing
ctrl +o
Hit return
to save. Then exit Nano by typing ctrl+x
Logitech t631 for mac. $70 Ultrathin Touch Mouse T631 for Mac is a wireless input device that complements Apple’s various MacBook models.
.bashrc File On Mac Os X
Step 5: Now we need to *activate your changes. Type
source .bash_profile
and watch your prompt change.My .bash_profile
I have been compiling my own set of aliases and configurations for years in which time I have borrowed copiously from others who have made their aliases available online. I can claim credit for very little of what follows. I recently became aware of alias.sh, a site making sharing BASH aliases easy. Check it out.
Update: Due to popular demand, my bash profile is now available as a Gist for your forking pleasure.
Without further ado, here is my .bash_profile:
Bashrc For Mac Os X 10.10
Update: If you enjoyed this post, you might also like:
Source Bashrc Macos
- A collection of Bash scripting utilities I compiled to make custom Bash programming easier.