0
2

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 3 years have passed since last update.

【OS X El Capitan 10.11以前】シェルスクリプトを使ってMacの隠しファイル・フォルダの表示/非表示を切り替えるアプリを作成する方法

Last updated at Posted at 2021-04-16

はじめに

本記事ではOS X El Capitan 10.11以前のMacでアイコンをクリックするたび,Macの隠しファイル・フォルダを表示/非表示を切り替るアプリを作成する方法について記述する.

macOS Sierra 10.12以降はキーボードショートカットで簡単に隠しファイル・フォルダ表示/非表示を切り替えができる.

キーボードショートカット: command + shift + .

コマンドラインを使用する場合

隠しファイル・フォルダ表示

defaults write com.apple.finder AppleShowAllFiles true ; killall Finder

隠しファイル・フォルダ非表示

defaults write com.apple.finder AppleShowAllFiles false ; killall Finder

いちいちコマンド入力するのは面倒である.

アプリ化するための手順

手順1:

Automatorの起動
Automator_icon.png

手順2:

新規ファイルの作成

キーボードショートカット: command + N

手順3:

アプリケーションを選択
Automator_ss1.png

手順4:

検索窓にシェルスクリプトと入力しenterキーを押下
Automator_ss2.png

手順5

「シェル」のドロップダウンから/bin/shを選択
Automator_ss3.png

手順6:

枠内に下記シェルスクリプトを記述

if defaults read com.apple.finder AppleShowAllFiles | grep -iqE '^(1|on|true|yes)$'

# 隠しファイル・フォルダ非表示
then
  defaults write com.apple.finder AppleShowAllFiles false ; killall Finder

# 隠しファイル・フォルダ表示
else
  defaults write com.apple.finder AppleShowAllFiles true ; killall Finder
fi

手順7:

名前をつけて「アプリケーション」フォルダに保存
(ここでは名前をHideSwitch.appとした)

キーボードショートカット: command + S

完成

アイコンをクリックするたび,Macの隠しファイル・フォルダの表示/非表示の切り替えが可能になった.

おまけ

アイコンの変更

せっかくなので,今回作成したアプリのアイコンを下記の画像に設定してみる.
HideSwitch_icon.png

画像を任意の場所に保存し,そのまま開き全範囲選択しコピー

キーボードショートカット: command + A
キーボードショートカット: command + C

今回作成したアプリを選択し情報を見る.

キーボードショートカット: command + I

赤枠部分を選択し画像を貼り付ける.

キーボードショートカット: command + V
Automator_ss4.png

アイコンが変更された.
Automator_ss5.png

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?