0
1

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 1 year has passed since last update.

QuickLook(qlmanage コマンドを利用、macOS 上)

Last updated at Posted at 2021-07-10

こんにちは
qlmanage コマンドを利用すると QuickLook 機能を使えます。ファイルをコマンドライン上から GUI 的にプレビュー可能です1

ファイル sample.md をプレビューする例。

$ qlmanage -p sample.md >/dev/null 2>/dev/null &

screenshot.jpg

  • ただし動作失敗する場合があるようです(Segmentation fault発生、原因不明)。

標準以外のファイルへの対応

標準では対応しない Powershell スクリプトファイル(sample.ps1)をプレビューできるよう、qlstephen をインストールし、説明にしたがって設定しました。

1. 準備

$ mdls -name kMDItemContentType sample.ps1 
kMDItemContentType = "dyn.ah62d4rv4ge81a63v"
$ brew install --cask qlstephen
  • 上記から得た kMDItemContentType の情報を Info.plist へ書き加える: ~/Library/QuickLook/QLStephen.qlgenerator/Contents/Info.plist 内へ、 <string>dyn.ah62d4rv4ge81a63v</string> の行を書き加える(<string>public.data</string> <string>public.content</string>の後)。

2. プレビュー

$ qlmanage -p sample.ps1 >/dev/null 2>/dev/null &
  • うまく動作しない場合、下記のリセットを実行した後、再度試してみる。
$ xattr -cr ~/Library/QuickLook/QLStephen.qlgenerator
$ qlmanage -r
qlmanage: resetting quicklookd
$ qlmanage -r cache
qlmanage: call reset on cache
  1. 参考:「コマンドラインから GUI を操作する

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?