I just found a workaround for a problem I was having with the subl
command for Sublime Text 3 when the MacPorts version of python is installed. The instructions
An Alias is a Macintosh Finder concept. When you make an Alias in the Finder, the Finder tracks it. When you move the original file or folder, the alias follows it.
A symbolic link is a Unix File System concept. When you make a symbolic link, it merely points to the original location. Move the original, and the symbolic link will point nowhere.
When you use a Mac application, and use the Open/Save dialog box, it will handle aliases because it uses the Finder API, and the Finder handles alias tracking.
Unix tools don't integrate with the Finder API, so can't track aliases. However, they work with the underlying Unix API which handles symbolic links. You can use ls
on a symbolic link because it uses the Unix API. Same with Python.
Back in the System 7/8/9 days, the file system couldn't handle symbolic links much like the Windows API uses shortcuts and not symbolic links. You needed aliases.
However, Mac OS X is a Unix based OS, so understands the concept of symbolic links. The Finder now treats symbolic links as it did aliases (except that symbolic links don't update when the original moves). The only reason for aliases is to be compatible with the old Finder file system.
EDIT: Another comment leads me to realize the alias I'm talking about is a mac-specific 'finder' alias, whereas the aliases in question here are bash 'shell' aliases. My mistake.
A symbolic, or soft, link points to a path: a location on the filesystem. If the file or folder located at the path is moved or renamed, the soft link will now point at nothing useful.
An alias can contain a reference to a path, or to a file ID, or both, depending on the implementation. On Mac OS X at least, the default is both, but the path is favoured over the file ID. That is, as long as something exists at the path referenced by your alias, your alias will point to the path, just like a symbolic link does. But, if nothing exists at the path referenced by your alias, it will instead point to the original file ID.
For example:
Suppose you create a file, and then create an alias for it, by specifying the file path. The alias now contains the file's file ID, as well as the file's path. The alias will by default follow the file's path to take you to the file.
If you now move the file to a different location, the alias will follow it by referencing the file's file ID. But, if you assign a NEW file to the same file path as the old one, the alias will now point to the new file, since it favours path over file ID.
Reference: http://forums.macworld.com/index.php?/topic/142842-aliases-vs-symbolic-links/
They're entirely different things, though in this case they can be used for similar purposes.
This:
alias subl="/Applications/path/to/subl"
creates an alias, so that typing subl
as a shell command is equivalent to typing /Applications/path/to/subl
.
In bash, functions are generally preferred to aliases, because they're much more flexible and powerful.
subl() { /Applications/path/to/subl ; }
Both these things are specific to the shell; they cause the shell to expand sub1
to a specified command.
ln -s
, on the other hand, creates a symbolic link in the file system. A symbolic link is a reference to another file, and for most purposes it can be treated as if it were the file itself. It applies to anything that accesses it, not just to the shell, it's immediately visible to all processes running on the system, and it persists until it's removed. (A symbolic link is implemented as a small special file containing the name of the target file.)
It is really a super question
There are 3 levels of aliases in this debate
Some different use cases:
Personally I use ln -s .. relative often.
I also use Finder make alias a lot. It is easy and links follows the items as they more around. But it does not work from bash - therefore I sometimes changes these links to **ln -s ...* when I need to start scripting.
I think you may be missing something in your alias command above -- it should have the form alias mumble="substitution"
and will cause any command you type beginning with mumble to be replaced by substitution. So if what you entered in your profile was alias subl="/Applications/path//to/subl"
then whenever you type subl at the start of a command, it is replaced by the full path.
ln
works by creating a reference in the file system from one thing to another.
The link you provide above suggests that ln
will not work with the version of Python provided in MacPorts.
Aliases only exists within the context of the shell (Bash, Sh, Zsh, etc.) but is not found in other applications whereas ln -s
creates a virtual file (a link that is) to an existing real file that could present itself like a new command and should be cognizable by most applications that calls other binaries. Aliases are similar to functions and variables only that they are more like command templates. Creating a function actually is more commendable.