Skip to content

Instantly share code, notes, and snippets.

@bobbytables
Created February 26, 2013 08:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbytables/5036846 to your computer and use it in GitHub Desktop.
Save bobbytables/5036846 to your computer and use it in GitHub Desktop.
Aliases and Profiles

So an alias in your terminal is a shortcut to a command, or command with arguments.

For example, Brendan has an alias for ll (double L) that does the ls -l command. Which as we showed will display a list of files vertically in your terminal instead the hard-to-read horizontal way.

These are extremely handy for when you see yourself doing the same command over and over, just make an alias!

To do so, we're going to add it to your profile file. This file is run everytime you start a new session in your terminal (so starting terminal, or a new tab).

Open up terminal. Type in: cd ~

Once in that directory. Type in: ls -lsa

Look for a file called either ".profile", ".bashrc", or ".bash_profile" If you have more than one of these files, just pick one for this next part. If you don't have any of these files, go ahead and imagine that you've picked ".bash_profile".

Then type subl FILENAME while replacing FILENAME with the name of the file in your directory. Keep the dot at the beginning!!!

This file may already have content in it depending on if you've had a previous setup. Skip to the bottom of the file, that's where we'll be adding our aliases.

So lets add an alias for the ls command to give us an easy way to show a list of files. In the end of the file you have open in Sublime, add this:

alias ll="ls -l"

Go ahead and save this file and head on back to your terminal.

Now that you're in your terminal, we need to "source" the profile file. What this means is that we're going to reexecute the file. Because remember when we start a new terminal window (or tab) it evaluates this file and declares aliases and such.

We can tell our terminal to reload our profile file without having to close it. Type in the following:

source FILENAME (replace FILENAME like you did above).

Now, you should be able to type in ll in your terminal and see a list of files! Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment