我的答案是基于一个类似问题的答案,该问题是关于如何在Objective-C和Cocoa中获取最前面窗口的路径(这显然来自Mac OS X Hints提示,这可能是您的确切问题).我测试了命令,它也将工作包含空格的目录路径.
cd "`osascript -e 'tell application "Finder" to POSIX path of (target of window 1 as alias)'`"
Run Code Online (Sandbox Code Playgroud)
使用bash?将此功能添加到您的bash配置文件中.
cdf () {
finderPath=`osascript -e 'tell application "Finder"
try
set currentFolder to (folder of the front window as alias)
on error
set currentFolder to (path to desktop folder as alias)
end try
POSIX path of currentFolder
end tell'`;
cd "$finderPath"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4400 次 |
| 最近记录: |