关闭。这个问题不符合 Stack Overflow guidelines 。它目前不接受答案。
想改善这个问题吗?更新问题,使其成为 Stack Overflow 的 on-topic。
2年前关闭。
Improve this question
标题说明了一切。我只想知道输入什么命令将工作目录更改为在前查找器窗口中打开的目录。
最佳答案
我的回答基于对类似 question about how to get the path of the front-most window in Objective-C and Cocoa 的回答(这显然来自 Mac OS X Hints 提示,这可能是您的确切问题)。我已经测试了该命令,它也可以使用包含空格的目录路径。
cd "`osascript -e 'tell application "Finder" to POSIX path of (target of window 1 as alias)'`"
使用 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"
}
关于macos - Mac 终端将目录更改为当前的前端查找器窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18456682/