Bashrc For Mac Os X

To make aliases of macOS Unix commands in your bash or zsh shell on macOS and earlier versions, it is done via your .bash_profile or .zsh file which lives in your home account directory, if the file does not already exist, just create one.

Wallpapers 1920x1080 for macbook air

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. If you put it in your.bashrc, you’d see it every time you open a new terminal window. Mac OS X — an exception. 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.bashprofile instead of.bashrc. Other GUI terminal emulators may do the same.

  1. Installing IRAF in a Linux or Mac OS X box has become easier than ever, as basically now one has to download a single tar file, and execute just a few commands to install also the most important external packages. The IRAF installation procedure should be valid for recent Mac OS X releases running on an 64-bit Intel CPU.
  2. I believe mac OS X environment checks.bashprofile,.bashlogin,.profile in this order. It will run whichever is the highest in the hierarchy, so, if you have.bashprofile, it will not check.profile.

Bashrc Mac Os X

As of macOS 10.6 Catalina, Apple has made the zsh shell the default shell, previously it was the bash shell.

Launch Terminal from the /Application/Utilities folder

Go to your home directory by just entering cd followed by the ‘return’ key to enter the command:

List your home directory contents including invisible files to see if the file already exists, use:

Create the .bash_profile or .zsh file using the command line program called ‘nano’ if it doesn’t exist:

Bashrc For Mac Os X

When the .bash_profile or .zsh file is created you are ready to enter your alias commands.
So here I am using the alias ‘l’ to alias the command ‘ls -lah’

In nano ‘control+o’ to write the file out and ‘control+x’ to exit the file.

Bashrc For Mac Os X

Refresh the shell environment by entering the command below:

Or.

That’s it, now the alias will take effect.

To add other aliases just start a new line, and apply the same formatting.

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

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.

Step 1: Fire up Terminal.app

Bashrc For Mac Os X 10.10

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

Step 5: Now we need to *activate your changes. Type source .bash_profile and watch your prompt change.

My .bash_profile

.bashrc File On Mac Os X

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:

Update: If you enjoyed this post, you might also like:

  • A collection of Bash scripting utilities I compiled to make custom Bash programming easier.