[Mac] 使用 defaults 指令讀取 plist 檔案

[Mac] 使用 defaults 指令讀取 plist 檔案

今天想看一下 Mac 上的 Preview app 的一些設定值,

因為用它來抓螢幕截圖的話,都會跑出一個陰影框,不是很喜歡,

但從 Preview 的 Preferences 設定那邊又沒得改…

 

查了一下,像 Preview 的一些設定值,

放在 ~/Library/Preferences/com.apple.Preview.plist,

這種 plist 檔直接 cat 都會是亂碼:

testuser@localhost ~/Library/Preferences $ cat ./com.apple.Preview.plist

bplist00_!NSNavPanelExpandedSizeForSaveMode_"NSNavPanelExpandedStateForSaveMode_NSNavLastRootDirectory_!NSNavPanelExpandedSizeForOpenModeZ{712, 557}	[~/DownloadsZ{720, 4485Zs����	�

 

要怎麼讀取 plist 檔案呢?

可以用 defaults 這個指令,像是 defaults read <plist file> 就可以顯示它的內容,

例如我想要顯示 com.apple.Preview 這個 .plist 的內容:

testuser@localhost ~/Library/Preferences $ defaults read com.apple.Preview

{
    NSNavLastRootDirectory = "~/Dropbox/Desktop";
    NSNavLastUserSetHideExtensionButtonState = 0;
    NSNavPanelExpandedSizeForOpenMode = "{1016, 606}";
    NSNavPanelExpandedSizeForSaveMode = "{852, 448}";
    NSNavPanelExpandedStateForSaveMode = 1;
    "NSSplitView Subview Frames NSColorPanelSplitView" =     (
        "0.000000, 0.000000, 224.000000, 263.000000, NO, NO",
        "0.000000, 264.000000, 224.000000, 43.000000, NO, NO"
    );
    "NSToolbar Configuration CommonToolbar_v5.1" =     {
        "TB Display Mode" = 2;
        "TB Icon Size Mode" = 1;
        "TB Is Shown" = 1;
        "TB Size Mode" = 1;
    };
    "NSToolbar Configuration com.apple.NSColorPanel" =     {
        "TB Is Shown" = 1;
    };
    "NSWindow Frame NSNavPanelAutosaveName" = "207 457 427 279 0 0 1440 877 ";
    "NSWindow Frame PVInspectorPanel" = "1116 624 320 249 0 0 1440 877 ";
    "NSWindow Frame PVPreferences" = "470 433 475 178 0 0 1440 877 ";
    PMPrintingExpandedStateForPrint2 = 1;
    "PVAnnotationColor_4" = {length = 71, bytes = 0x040b7374 7265616d 74797065 6481e803 ... 3f8369f8 913e0186 };
    "PVAnnotationColor_8" = {length = 71, bytes = 0x040b7374 7265616d 74797065 6481e803 ... 3f835c19 6e3f0186 };
    "PVAnnotationInteriorColor_0" = {length = 55, bytes = 0x040b7374 7265616d 74797065 6481e803 ... 03840266 66000086 };
    "PVAnnotationInteriorColor_8" = {length = 55, bytes = 0x040b7374 7265616d 74797065 6481e803 ... 03840266 66000086 };
    PVContactSheetThumbnailSize = 120;
    PVGeneralSelectedPane = 1;
    PVImageSizeResolutionUnit = 10;
    PVImageSizeSizeUnit = 5;
    "PVInspectorPanelForDoctype_ImageDocument" = PVInspectorImageFileInfo;
    "PVInspectorPanelForDoctype_NoDocument" = PVInspectorNoDocument;
    "PVInspectorPanelForDoctype_PDFDocument" = PVInspectorPDFFileInfo;
    PVInspectorTabForMetaData = "{JFIF}";
    PVInspectorWindowOpenOnStart = 0;
    PVPDFLastSidebarWidth = 212;
    PVSidebarViewModeForNewDocuments = 0;
    RawCameraSupportVersion = 7040;
    "com.apple.AnnotationKit.arrowHeadStyle" = 3;
    "com.apple.AnnotationKit.brushStyle" = 0;
    "com.apple.AnnotationKit.fillColor" = {length = 242, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 000000b8 };
    "com.apple.AnnotationKit.font" = {length = 506, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 00000184 };
    "com.apple.AnnotationKit.hasShadow" = 0;
    "com.apple.AnnotationKit.highlightStyle" = 765200;
    "com.apple.AnnotationKit.strokeColor" = {length = 254, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 000000c2 };
    "com.apple.AnnotationKit.strokeIsDashed" = 0;
    "com.apple.AnnotationKit.strokeWidth" = 3;
    "com.apple.AnnotationKit.textAttributes" = {length = 278, bytes = 0x7b5c7274 66315c61 6e73695c 616e7369 ... 205c6366 3220617d };
    "com.apple.AnnotationKit.userDefaultsVersion" = 1;
    kPVInspectorPDFMetricsUnit = 4;
    selectedDPI = 150;
    selectedUnit = 0;
}

 

如上,可以看到不少設定值,

不過似乎是沒有與截圖陰影有關的東西。

但至少學到了讀取 plist 檔案內容的方法啦~

(本頁面已被瀏覽過 510 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料