作ったもの
タイトル通りMacのFinderで開いているディレクトリにcdできるコマンドを随分前に作りました。Apple Scriptの部分は誰かのコードから拝借しました(すみません出典を覚えてません)。このコードを~/.config/fish/functions
にcdf.fish
という名前で保存すれば使えるようになります。
コード
function cdf
set target (osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)')
if test -n "$target"
cd $target
pwd
else
echo 'No Finder window found' >&2
false
end
end