3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacのFinderで開いているディレクトリにcdできるコマンド作った(Fish shell)

Posted at

作ったもの

タイトル通りMacのFinderで開いているディレクトリにcdできるコマンドを随分前に作りました。Apple Scriptの部分は誰かのコードから拝借しました(すみません出典を覚えてません)。このコードを~/.config/fish/functionscdf.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
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?