├── .travis.yml ├── .gitignore ├── snippets.md ├── glossary.md ├── launchagents.md ├── functions.md └── README.md /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | 3 | rvm: 4 | - 2.2 5 | 6 | before_script: 7 | - gem install awesome_bot 8 | 9 | script: 10 | - awesome_bot README.md --allow-dupe --allow-redirect --white-list example.com,web.archive.org 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | # *.[oa] 6 | # *~ 7 | .DS_Store 8 | .idea 9 | -------------------------------------------------------------------------------- /snippets.md: -------------------------------------------------------------------------------- 1 | # 片段 2 | 3 | > 各种有用的 Bash 风格命令,可随时复制、粘贴。 4 | > [Awesome OS X Command Line](https://github.com/nusr/awesome-macos-command-line-zh) 的一部分。 5 | 6 | - [片段](#%E7%89%87%E6%AE%B5) 7 | - [文本操作](#%E6%96%87%E6%9C%AC%E6%93%8D%E4%BD%9C) 8 | - [从文本中提取唯一单词](#%E4%BB%8E%E6%96%87%E6%9C%AC%E4%B8%AD%E6%8F%90%E5%8F%96%E5%94%AF%E4%B8%80%E5%8D%95%E8%AF%8D) 9 | 10 | ## 文本操作 11 | 12 | ### 从文本中提取唯一单词 13 | 14 | ```bash 15 | grep -o -E '\w+' | sort -u -f 16 | ``` 17 | -------------------------------------------------------------------------------- /glossary.md: -------------------------------------------------------------------------------- 1 | ### Mac OS 版本信息 2 | 3 | | 版本 | 名称 | 发布日期 | 最新版本 | 4 | | -------------------------- | ------------------ | ------------------ | ------------------------------------- | 5 | | Rhapsody Developer Release | Grail1Z4 / Titan1U | August 31, 1997 | DR2 (May 14, 1998) | 6 | | Mac OS X Server 1.0 | Hera | March 16, 1999 | 1.2v3 (October 27, 2000) | 7 | | Mac OS X Developer Preview | n/a | March 16, 1999 | DP4 (April 5, 2000) | 8 | | Mac OS X Public Beta | Kodiak | September 13, 2000 | n/a | 9 | | Mac OS X 10.0 | Cheetah | March 24, 2001 | 10.0.4 (June 22, 2001) | 10 | | Mac OS X 10.1 | Puma | September 25, 2001 | 10.1.5 (June 6, 2002) | 11 | | Mac OS X 10.2 | Jaguar | August 24, 2002 | 10.2.8 (October 3, 2003) | 12 | | Mac OS X 10.3 | Panther | October 24, 2003 | 10.3.9 (April 15, 2005) | 13 | | Mac OS X 10.4 | Tiger | April 29, 2005 | 10.4.11 (November 14, 2007) | 14 | | Mac OS X 10.5 | Leopard | October 26, 2007 | 10.5.8 (August 5, 2009) | 15 | | Mac OS X 10.6 | Snow Leopard | August 28, 2009 | 10.6.8 v1.1 (July 25, 2011) | 16 | | Mac OS X 10.7 | Lion | July 20, 2011 | 10.7.5 (September 19, 2012) | 17 | | OS X 10.8 | Mountain Lion | July 25, 2012 | 10.8.5 (12F45) (October 3, 2013) | 18 | | OS X 10.9 | Mavericks | October 22, 2013 | 10.9.5 (13F1112) (September 18, 2014) | 19 | | OS X 10.10 | Yosemite | October 16, 2014 | 10.10.5 (14F27) (August 13, 2015) | 20 | | OS X 10.11 | El Capitan | September 30, 2015 | 10.11.6 (15G31) (July 18, 2016) | 21 | | macOS 10.12 | Sierra | September 20, 2016 | 10.12.6 (16G29) (July 19, 2017) | 22 | | macOS 10.13 | High Sierra | September 25, 2017 | 10.13.6 (17G65) (July 9, 2018) | 23 | | macOS 10.14 | Mojave | September 24, 2018 | 10.14 (18A391) (September 24, 2018) | 24 | -------------------------------------------------------------------------------- /launchagents.md: -------------------------------------------------------------------------------- 1 | # 自启动服务 2 | 3 | > 各种有用的自启动服务例子。 [Awesome OS X Command Line](https://github.com/nusr/awesome-macos-command-line-zh) 的一部分 4 | 5 | - [自启动服务](#%E8%87%AA%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1) 6 | - [基本例子](#%E5%9F%BA%E6%9C%AC%E4%BE%8B%E5%AD%90) 7 | - [定时工作模板](#%E5%AE%9A%E6%97%B6%E5%B7%A5%E4%BD%9C%E6%A8%A1%E6%9D%BF) 8 | - [按照日历定期工作模板](#%E6%8C%89%E7%85%A7%E6%97%A5%E5%8E%86%E5%AE%9A%E6%9C%9F%E5%B7%A5%E4%BD%9C%E6%A8%A1%E6%9D%BF) 9 | - [监控文件夹模板](#%E7%9B%91%E6%8E%A7%E6%96%87%E4%BB%B6%E5%A4%B9%E6%A8%A1%E6%9D%BF) 10 | - [Homebrew](#homebrew) 11 | - [定时更新 Homebrew](#%E5%AE%9A%E6%97%B6%E6%9B%B4%E6%96%B0-homebrew) 12 | - [License](#license) 13 | 14 | ## 基本例子 15 | 16 | ### 定时工作模板 17 | 18 | 每5分钟运行一次。 19 | 20 | ```xml 21 | 22 | 23 | 24 | 25 | Label 26 | com.example.touchsomefile 27 | ProgramArguments 28 | 29 | touch 30 | /tmp/helloworld 31 | 32 | StartInterval 33 | 300 34 | 35 | 36 | ``` 37 | 38 | ### 按照日历定期工作模板 39 | 40 | ```xml 41 | 42 | 43 | 44 | 45 | Label 46 | com.example.touchsomefile 47 | ProgramArguments 48 | 49 | touch 50 | /tmp/helloworld 51 | 52 | StartCalendarInterval 53 | 54 | Minute 55 | 45 56 | Hour 57 | 13 58 | Day 59 | 7 60 | 61 | 62 | 63 | ``` 64 | 65 | ### 监控文件夹模板 66 | 67 | ```xml 68 | 69 | 70 | 71 | 72 | Label 73 | com.example.watchhostconfig 74 | ProgramArguments 75 | 76 | syslog 77 | -s 78 | -l 79 | notice 80 | somebody touched /etc/hostconfig 81 | 82 | WatchPaths 83 | 84 | /etc/hostconfig 85 | 86 | 87 | 88 | ``` 89 | 90 | ## Homebrew 91 | 92 | ### 定时更新 Homebrew 93 | 94 | 为了使用通知系统,这个功能需要先安装[terminal-notifier](https://github.com/julienXX/terminal-notifier)。可以通过 `brew install terminal-notifier` 安装 terminal-notifier。 95 | ```xml 96 | 97 | 98 | 99 | 100 | Label 101 | com.example.homebrew-upgrade 102 | ProcessType 103 | Background 104 | ProgramArguments 105 | 106 | /bin/sh 107 | -c 108 | /usr/local/bin/brew update && /usr/local/bin/brew upgrade && /usr/local/bin/terminal-notifier -title 'Homebrew Upgrader' -message 'Homebrew upgraded!' -appIcon http://cdn.curvve.com/wp-content/uploads/2013/09/homebrew_osx_logo.png 109 | 110 | RunAtLoad 111 | 112 | StandardErrorPath 113 | /tmp/com.example.homebrew-upgrade.stderr 114 | StandardOutPath 115 | /tmp/com.example.homebrew-upgrade.stdout 116 | StartCalendarInterval 117 | 118 | 119 | Hour 120 | 8 121 | 122 | 123 | 124 | 125 | ``` 126 | 127 | ## License 128 | 129 | Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. 130 | -------------------------------------------------------------------------------- /functions.md: -------------------------------------------------------------------------------- 1 | 2 | # 函数 3 | 4 | > OS X 特定 Bash 风格的好用函数集合。[Awesome OS X Command Line](https://github.com/nusr/awesome-macos-command-line-zh) 的一部分。 5 | 6 | - [函数](#%E5%87%BD%E6%95%B0) 7 | - [开发者](#%E5%BC%80%E5%8F%91%E8%80%85) 8 | - [应用图标](#%E5%BA%94%E7%94%A8%E5%9B%BE%E6%A0%87) 9 | - [助手功能](#%E5%8A%A9%E6%89%8B%E5%8A%9F%E8%83%BD) 10 | - [访达](#%E8%AE%BF%E8%BE%BE) 11 | - [获取最前面的访达窗口的路径](#%E8%8E%B7%E5%8F%96%E6%9C%80%E5%89%8D%E9%9D%A2%E7%9A%84%E8%AE%BF%E8%BE%BE%E7%AA%97%E5%8F%A3%E7%9A%84%E8%B7%AF%E5%BE%84) 12 | - [打印访达中选中的文件](#%E6%89%93%E5%8D%B0%E8%AE%BF%E8%BE%BE%E4%B8%AD%E9%80%89%E4%B8%AD%E7%9A%84%E6%96%87%E4%BB%B6) 13 | - [将当前访达文件目录设置为分栏视图](#%E5%B0%86%E5%BD%93%E5%89%8D%E8%AE%BF%E8%BE%BE%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95%E8%AE%BE%E7%BD%AE%E4%B8%BA%E5%88%86%E6%A0%8F%E8%A7%86%E5%9B%BE) 14 | - [将当前访达文件目录设置为图标视图](#%E5%B0%86%E5%BD%93%E5%89%8D%E8%AE%BF%E8%BE%BE%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95%E8%AE%BE%E7%BD%AE%E4%B8%BA%E5%9B%BE%E6%A0%87%E8%A7%86%E5%9B%BE) 15 | - [将当前访达文件目录设置为列表视图](#%E5%B0%86%E5%BD%93%E5%89%8D%E8%AE%BF%E8%BE%BE%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95%E8%AE%BE%E7%BD%AE%E4%B8%BA%E5%88%97%E8%A1%A8%E8%A7%86%E5%9B%BE) 16 | 17 | ## 开发者 18 | 19 | ### 应用图标 20 | 21 | #### 创建应用图标 22 | 23 | 由 1024 x 1024 图片快速创建应用图标的函数。 24 | 25 | ```bash 26 | function mkicns() { 27 | if [[ -z "$@" ]]; then 28 | echo "Input file missing" 29 | else 30 | filename=${1%.*} 31 | mkdir $filename.iconset 32 | sips -z 16 16 $1 --out $filename.iconset/icon_16x16.png 33 | sips -z 32 32 $1 --out $filename.iconset/icon_16x16@2x.png 34 | sips -z 32 32 $1 --out $filename.iconset/icon_32x32.png 35 | sips -z 64 64 $1 --out $filename.iconset/icon_32x32@2x.png 36 | sips -z 128 128 $1 --out $filename.iconset/icon_128x128.png 37 | sips -z 256 256 $1 --out $filename.iconset/icon_128x128@2x.png 38 | sips -z 256 256 $1 --out $filename.iconset/icon_256x256.png 39 | sips -z 512 512 $1 --out $filename.iconset/icon_256x256@2x.png 40 | sips -z 512 512 $1 --out $filename.iconset/icon_512x512.png 41 | cp $1 $filename.iconset/icon_512x512@2x.png 42 | iconutil -c icns $filename.iconset 43 | rm -r $filename.iconset 44 | fi 45 | } 46 | ``` 47 | 48 | ### 助手功能 49 | 50 | #### 向用户询问密码 51 | 52 | 使用 AppleScript 创建密码输入框,对用户更友好。 53 | 54 | ```bash 55 | function gui_password { 56 | if [[ -z $1 ]]; then 57 | gui_prompt="Password:" 58 | else 59 | gui_prompt="$1" 60 | fi 61 | PW=$(osascript <