Create Alias For Mac

Create Alias For Mac

Home > Articles > Apple > Operating Systems

To create an alias in bash that is set every time you start a shell: Open your /.bashprofile file. Add a line with the alias—for example, alias lf='ls -F' Save the file. Quit the editor. The new alias will be set for the next shell you start. Open a new Terminal window to check that the alias is set: alias. You should see your new alias. You can drag the Folder to your dock (between the trash and the sepperator to the applications), or to the sidebar in Finder. You can also create an Alias (this is what you need to do if you want to put it in a folder or to the desktop) by dragging the folder and then holding the Option ⌥ and Command ⌘ keys together while you release the mouse button (a small arrow will appear in the lower.

  1. Finding Configuration Files
Page 1 of 7Next >
Learn how to customize your OS X environment, including the shell prompt, shortcuts, installation of new software, and vi, by changing your configuration files, environment variables, and tbe path.
This chapter is from the book
UNIX for Mac OS X: Visual QuickPro Guide

This chapter is from the book

This chapter is from the book

Many user-configurable Unix programs (such as your shell) read configuration files when they start up. These configuration files contain settings and commands that determine how the programs will behave—for instance, the files can modify the list of places your shell looks for the commands you enter (that list is called your PATH).

You change your Unix environment to have it more closely match your personal preferences and to shape it more closely to the way you work.

Examples of configuring your Unix environment include:

  • Customizing your shell prompt so that it displays information you want to see.

  • Creating shortcuts for commonly used command/option combinations (these can be 'aliases,' but they are distinct from the aliases you create in the Finder, and from the shell functions, which are short scripts that are part of your private configuration).

  • Making it easier to use additional software you install; for example, if you add /Developer/Tools to your PATH, then you can use the commands in the /Developer/Tools directory without typing their full pathnames.

  • Configuring specific programs such as vi to turn on various options whenever you use them, much the same way that traditional Mac programs often have a preferences dialogue box.

The first program to configure is your shell, since your shell is the primary program you use to interact with Unix. We will also show you how to configure the vi editor by editing a configuration file it uses (see Chapter 6, 'Editing and Printing Files,' to learn how to use vi).

It should come as no surprise by now that you configure your shell by editing text files.

Finding Configuration Files

User-configurable Unix programs (including your shell, the vi editor, and others) look for configuration files in your home directory when they start up. Most of the commands you have learned so far are not user-config-urable; neither the ls nor the cd command uses configuration files, for example. They do accept options on the command line but do not read any configuration files when you run them.

Many configuration filenames begin with a dot (.), so they are called dot files (use ls -a to see them). Often the filenames end in 'rc' (for resource). For example, the main config-uration file for the tcsh shell is ~/.tcshrc, a configuration file for the bash shell is ~/.bash_profile, and the configuration file for the vi editor is called ~/.exrc (ex is an older editor, and vi provides a 'visual interface' for it). There are actually several config-uration files available for each shell, and Table 7.1 lists the more common ones. In this chapter, we will concentrate on the ones you would change in the course of normal use. These files each have settings and commands for the particular program being configured. (Remember that ~ [the tilde] is a synonym for your home directory.)

Configuration files for shells are actually scripts. This means they are a series of commands written in the scripting language for the corresponding shell. They make use of variables, if-then conditions, and other scripting elements such as loops. (See Chapter 9, 'Creating and Using Scripts,' for more on scripts.)

Table 7.1 A Summary of Common Shells

Shell

Name and Description

sh

Bourne shell. The oldest and most standardized shell. Widely used for system startup files (scripts run during system startup). Installed in Mac OS X.

bash

Bash (Bourne Again SHell) is an improved version of sh. Combines features from csh, sh, and ksh. Very widely used, especially on Linux systems. See the Bash Reference Manual online (http://www.gnu.org/manual/bash/). Installed in Mac OS X.

csh

C shell. Provides scripting features that have a syntax similar to that of the C programming language (originally written by Bill Joy). Installed in Mac OS X.

ksh

Korn shell. Developed at AT&T by David Korn in the early 1980s. Ksh is widely used for programming. It is now open-source software, although you must agree to AT&T's license to install it. See the KornShell Web site (http://www.kornshell.com).

tcsh

An improved version of csh. The t in tcsh comes from the TENEX and TOPS-20 operating systems, which provided a command-completion feature that the creator (Ken Greer) of tcsh included in his new shell. Wilfredo Sanchez, formerly lead engineer on Mac OS X for Apple, worked on tcsh in the early 1990s at the Massachusetts Institute of Technology.

zsh

Z shell. Created in 1990, zsh combines features from tcsh, bash, and ksh, and adds many of its own. Installed in Mac OS X. The Web site for Z shell is http://zsh.sourceforge.net.


Am I Configuring the Terminal Application or My Shell?

There's an important distinction to understand here.

The Terminal application you are using to access the command line in Mac OS X is not the same as your shell.

Terminal is a regular Mac OS X graphical application, like your Web browser or word processor. When you open a new window in Terminal, the application runs the appropriate Unix shell (determined by the Terminal application's preferences). Terminal is the program that is handling the screen display and keyboard input for the shell. When you type something in Terminal, the Terminal application passes that to the shell, and when the shell produces output, Terminal draws it on your screen.

The subtle point here is that there are actually other ways besides Terminal in which you can use your shell. One example: You can connect to your Mac using the command line over a network from another machine, which we'll cover in Chapter 10, 'Interacting with Other Unix Machines.' So when we tell you in this chapter that a change you make will take effect 'in the next Terminal window you open,' that is really a shorthand way of saying that the change will take effect in the next instance of your shell that you run, and that the easiest way to see it is to open a new Terminal window.

Related Resources

  • Book $31.99
  • eBook (Watermarked) $25.59
  • eBook (Watermarked) $38.39

This guide will explain how to create aliases (sometimes called “shortcuts”) on your Mac.

Macos Bash Alias

An alias is a file or folder that points to another file or folder. Initially that might seem rather unnecessary, but the more you use them the more useful you find them. You can move aliases around and not have to worry about or track down the original file. Or create folders full of aliases to specific Apps – eg. a folder with aliases to all of your graphics Apps.
There are a number of ways to create an alias. The easiest is to right-click (or Control + click for single-button mouse folks) the file or folder you want to create an alias of and select Make Alias from the contextual menu.

You can also select the file/folder in Finder and then choose File ->Make Alias

A third way to create an alias is to hold down the Option and Command keys when you drag and drop a file or folder and instead of moving or copying the file, it will create an alias of it.

Create Alias Mac Os Terminal

Aliases are easily recognizable by the small ‘arrow’ that gets added to the bottom left corner of each icon (see screenshot below).

Another use for aliases is to add a folder full of them to your Dock and use it as a launcher for a custom group of files.