ANSI Colorの名称一覧から名前をえらんで、Terminalの文字色を変更するAppleScriptです。
これにどの程度の意味があるのかさっぱり分からないのですが、ANSI Colorで文字色を指定する趣味の人もいるということで、世界の広さを感じます。
▲Select ANSI color name
▲Before
▲After
AppleScript名:ANSI Colorの色名称でTerminalの文字色を変更 |
— Created 2018-02-06 by Takaaki Naganoya — 2018 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" –Dark –set ansiColTable to {{colName:"Black", colVal:{0, 0, 0}}, {colName:"Red", colVal:{34166, 0, 712}}, {colName:"Green", colVal:{5182, 39392, 620}}, {colName:"Yellow", colVal:{34811, 35431, 1086}}, {colName:"Blue", colVal:{0, 0, 39429}}, {colName:"White", colVal:{49207, 49511, 49827}}, {colName:"Magenta", colVal:{41397, 0, 41833}}, {colName:"Cyan", colVal:{4997, 38685, 41818}}} –Light set ansiColTable to {{colName:"Black", colVal:{21352, 21356, 21351}}, {colName:"Red", colVal:{56616, 0, 1392}}, {colName:"Green", colVal:{7241, 55116, 1162}}, {colName:"Yellow", colVal:{57396, 58567, 2377}}, {colName:"Blue", colVal:{0, 0, 65416}}, {colName:"White", colVal:{49207, 49511, 49827}}, {colName:"Magenta", colVal:{56440, 0, 57441}}, {colName:"Cyan", colVal:{7416, 58001, 57206}}} set tmpColorList to filterAnAttribute(ansiColTable, "colName") of me set aTargColor to choose from list tmpColorList with prompt "choose ANSI color name" if aTargColor = {} or aTargColor = false then return set targColorName to contents of first item of aTargColor set aRes to filterListUsingPredicate(ansiColTable, "colName ==[c] %@", targColorName) if aRes = missing value then return set colList to colVal of aRes tell application "Terminal" set normal text color of window 1 to colList –set background color of window 1 to colList end tell on filterListUsingPredicate(aList as list, aPredicateStr as string, targStr as string) set setKey to current application’s NSMutableSet’s setWithArray:aList set aPredicate to current application’s NSPredicate’s predicateWithFormat_(aPredicateStr, targStr) set aRes to (setKey’s filteredSetUsingPredicate:aPredicate) return (aRes’s allObjects()) as list of string or string end filterListUsingPredicate on filterAnAttribute(aList as list, anAttr as string) set anArray to current application’s NSArray’s arrayWithArray:aList set valList to anArray’s valueForKeyPath:anAttr return valList as list of string or string –as anything end filterAnAttribute |
More from my site
(Visited 158 times, 1 visits today)