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 say to put a soft link, ln-s
to the command line app in your /bin. That didn't work, so I just opened my ~/.profile and added an alias:
alias subl="/Applications/path/to/subl"
.
But that begs a new question for me. What is the difference between these two: alias and soft links?
相关问题
- How to get the return code of a shell script in lu
- JQ: Select when attribute value exists in a bash a
- Invoking Mirth Connect CLI with Powershell script
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- In IntelliJ IDEA, how can I create a key binding t
- Check if directory exists on remote machine with s
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- xcode 4 garbage collection removed?
ln -s
creates a symbolic link, which is almost a file on your filesystemalias is a shell specific thing
So, basically, a symbolic link is a better solution because it is going to work for everything. Like, if you want to make your file manager open text files with that specific program, you can point it to your symbolic link and it is going to work.
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 wasalias 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.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/
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.
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.