LoginSignup
88

More than 1 year has passed since last update.

macOS の .DS_Store を一括削除する

Last updated at Posted at 2016-02-28

macOS で開発している(ドットファイルを表示している)人であれば、誰しもが削除しては復活する .DS_Store をどうにかしたいと思ったことがあるはず。

Finder の設定などを格納する一時ファイルなので、作らない設定にすると Finder の振る舞いがおかしくなったりするなんていうウワサもある。しかし、間違って git 管理下に追加してしまったりなどオペレーション上のミスを招くこともゼロではない。

ワンライナーで削除

そんな忌まわしき .DS_Store を一括で削除コマンドがこちら。またすぐ復活するけど。

$ find . -name '.DS_Store' -type f -ls -delete

alias dsstore="find . -name '*.DS_Store' -type f -ls -delete" のように、エイリアスを .bashrc なり .zshrc なりに書いておくと dsstore コマンドで使えるようになる。

dsstore モジュール

なんとなく Node.js のモジュールを作ってみた。 npm install -g dsstore-cli すれば同じく dsstore コマンドがパスに追加される。find コマンドによる削除より実行時の見た目が改善されているが、ただそれだけ。

$ npm install -g dsstore-cli
$ dsstore --help

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
88