LoginSignup
10
14

More than 5 years have passed since last update.

[Mac]Finderで表示している画面に、terminal上でコマンドで移動する #自分メモ

Posted at

はじめに

自分の環境がMacになったので、備忘録的に色々とメモとして残しておくことに
.bashrcに書き足して、terminaLife(なにそれ)を充実していく過程でやったことを

.bashrcに以下を書き加える

cdf () {
        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 [ "$target" != "" ]
        then
                cd "$target"
                pwd
        else
                echo 'No Finder window found' >&2
        fi
}

Finderで作業したあと…

terminal上で[cdf]とコマンドを打てばそのディレクトリに移動可能。
これで素敵なterminaLifeがおくれますね!!

おまけ

openコマンドもaliasに登録しておくと、terminal↔︎Finderの関係がとても楽になる

alias f='open .'

source ~/.bash_profileも忘れずに!

これがQiita初投稿ですね。markdown便利ですね

参考にさせていただいたところ

jumping to the finder location in terminal

10
14
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
10
14