将项目添加到 Finder 侧边栏
我想向 Finder 侧边栏添加一个新项目。我发现 Finder 将“地点”列表保存在 `~/Library/Preferences/com.apple.sidebarlists.plist 中。我能够使用 Carbon API 读取该文件,并看到每个项目都有名称、图标和别名。
使用 PlistEdit Pro 等第三方应用程序,我能够更新别名。我的问题是如何使用 Carbon API 更新别名。无法找到创建将在 Finder 中打开的别名的方法。看来 Dropbox 和 PlistEditor Pro 都能够找到方法。
I would like to add a new item to the Finder sidebar. I found out that the Finder keeps the list of "places" in `~/Library/Preferences/com.apple.sidebarlists.plist. I was able to read the file using Carbon API and saw that each item had Name, icon and alias.
Using a 3rd party application such as PlistEdit Pro I was able to update the alias. My question is how to update the alias using Carbon API. Was not able to find a way to create alias that will open in Finder. It seem that both Dropbox and PlistEditor Pro was able to find the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看此处:
您想要查找键 kLSSharedFileListFavoriteItems,它处理侧边栏中“位置”下的项目。
我想你可以尝试做类似的事情 这个,使用LSSharedFileListCreate创建kLSSharedFileListFavoriteItems。
或者您可以使用此处发布的applescript,会更容易,但不是“正确的方式”©
Take a look here:
You want to look for the key kLSSharedFileListFavoriteItems, which handles the items under "Places" in the Sidebar.
I guess you could try to do something similar to this, using LSSharedFileListCreate to create kLSSharedFileListFavoriteItems.
Or you could use the applescript posted here, which would be way easier, but not the "Right Way"©
2015 年更新
LSSharedFileList
标头表示该内容已移至 CoreServices 框架。事实上,如果您按 Cmd-Shift-O(在 Xcode 中)并输入 LSSharedFileList,然后导航到唯一的结果,您将在跳转栏中看到标头现在确实包含在CoreServices.framework
。无论如何,关键仍然是kLSSharedFileListFavouriteItems
。示例:
用法:
Update for 2015
The
LSSharedFileList
header says this has moved to the CoreServices framework. In fact, if you Cmd-Shift-O (in Xcode) and type LSSharedFileList, then navigate to the only result, you'll see in the jump bar that the header is indeed now contained withinCoreServices.framework
. In any case, the key is stillkLSSharedFileListFavoriteItems
.Example:
Usage:
@Asmus:默认情况下,“command + T”是将文件夹添加到查找器侧边栏的快捷方式。当手动将键盘快捷键“command + T”分配给其他任务时,u 指向的 Applescript 工作正常。
更新 2023: 由于 Finder 和其他应用程序中选项卡的可用性,< code>command + T 创建一个新选项卡。新的默认快捷键是
command + ctrl + T
!@Asmus : By default 'command + T' is the shortcut to add a folder to sidebar in finder. Applescript pointed by u is working fine when keyboard shortcut key 'command + T' is assigned manually to other tasks.
Update 2023: Due to the availability of Tabs in Finder and other applications,
command + T
creates a new Tab. The new default shortcut iscommand + ctrl + T
!