mattintosh note

どこかのエンジニアモドキの備忘録

ドットファイルのエイリアスを作成する

Finder でドットファイルエイリアスを作成しても「.foo のエイリアス」になり、結局ドットファイルのままで表示されない。

方法1)Finder に不可視項目を表示して作成する

defaults write com.apple.finder AppleShowAllFiles yes && killall Finder

これで不可視項目が Finder に表示されるのでエイリアス作成後にリネームする。

元に戻す場合はブール値を反転させるかキーを消す。

defaults write com.apple.finder AppleShowAllFiles no && killall Finder

方法2)AppleScript を使う

make alias を使ってエイリアスを作成する。with properties recordエイリアスの名前を変更することができる。

make new alias at LOCATION to ORIGIN with properties {name:"NAME"}
# デスクトップに作成
osascript -e 'tell app "Finder" to make new alias at desktop to alias ((home as text) & ".foo") with properties {name:"foo"}'

# ホームに作成
osascript -e 'tell app "Finder" to make new alias at home to alias ((home as text) & ".foo") with properties {name:"foo"}'

方法3)エイリアスを作ってターミナルでリネームする

Finder の移動コマンドでドットファイルの中へ移動しパスバーなどから適当にエイリアスを作っておく。

mv .foo\ のエイリアス foo\ のエイリアス


しかしドットファイルを移動する機会なんて無かった…。