├── .gitignore ├── README.md ├── commands.rb ├── icon.png ├── info.plist ├── package └── alfred-terminal-commands.alfredworkflow ├── screenshot.png └── script.rb /.gitignore: -------------------------------------------------------------------------------- 1 | related_words.rb 2 | osx-terminal-commands.txt 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Search OS X Terminal commands using Alfred 2 2 | 3 | Use this workflow to search OS X Terminal commands by keyword and paste the command into Terminal. 4 | 5 | ## Usage 6 | Type `cmd [keyword]` (or set your own shortcut) to search available terminal commands. Press `ENTER` to copy the command to the clipboard and paste it in the front-most app (e.g. Terminal). 7 | 8 | ## Install 9 | 10 | Clone this repo and double-click the `alfred-terminal-commands.workflow` file or download [just the workflow file](https://github.com/gnestor/alfred-terminal-commands/raw/master/package/alfred-terminal-commands.alfredworkflow). 11 | 12 | ## Screenshots 13 | 14 | ![](https://raw.githubusercontent.com/gnestor/alfred-terminal-commands/master/screenshot.png) 15 | 16 | ## To do 17 | 18 | * Add a "related words" file to expose more keywords than just the command or its description 19 | 20 | * Display the `--help` docs for selected command 21 | 22 | * Display the `man` docs for selected command 23 | 24 | * Generate personalized index for user/system using `compgen -ca` 25 | 26 | ## Thanks to 27 | 28 | [alfred-emoji-workflow](https://github.com/carlosgaldino/alfred-emoji-workflow): Alfred workflow template 29 | 30 | [SS64](http://ss64.com/osx/): List of OS X Terminal commands and descriptions 31 | -------------------------------------------------------------------------------- /commands.rb: -------------------------------------------------------------------------------- 1 | COMMANDS = { 2 | 'Create an alias' => 'alias', 3 | 'List used and free memory' => 'alloc', 4 | 'Search the whatis database for strings' => 'apropos', 5 | 'Apple Software Restore' => 'asr', 6 | 'Find and Replace text within file(s)' => 'awk', 7 | 'Convert a full pathname to just a filename' => 'basename', 8 | 'Bourne-Again SHell' => 'bash', 9 | 'Send to background' => 'bg', 10 | 'Display readline key and function bindings' => 'bind', 11 | 'Set volume bootability and startup disk options' => 'bless', 12 | 'Exit from a For, While, Until or Select loop' => 'break', 13 | 'Execute a shell builtin' => 'builtin', 14 | 'Compress or decompress files' => 'bzip2', 15 | 'Display a calendar' => 'cal', 16 | 'Reminder Service' => 'calendar', 17 | 'Return the context of a subroutine call' => 'caller', 18 | 'Conditionally perform a command' => 'case', 19 | 'Concatenate and print (display) the content of files' => 'cat', 20 | 'Change Directory' => 'cd', 21 | 'Change a file or folder\'s flags' => 'chflags', 22 | 'Change group ownership' => 'chgrp', 23 | 'Change access permissions' => 'chmod', 24 | 'Change file owner and group' => 'chown', 25 | 'Run a command with a different root directory' => 'chroot', 26 | 'Print CRC checksum and byte counts' => 'cksum', 27 | 'Clear terminal screen' => 'clear', 28 | 'Compare two files' => 'cmp', 29 | 'Compare two sorted files line by line' => 'comm', 30 | 'Run a command (not a function)' => 'command', 31 | 'Edit a command completion [word/pattern/list]' => 'complete', 32 | 'Resume the next iteration of a loop' => 'continue', 33 | 'Copy one or more files to another location' => 'cp', 34 | 'Daemon to execute scheduled commands' => 'cron', 35 | 'Schedule a command to run at a later date/time' => 'crontab', 36 | 'Split a file into context-determined pieces' => 'csplit', 37 | 'Transfer data from or to a server' => 'curl', 38 | 'Divide a file into several parts' => 'cut', 39 | 'Display or change the date & time' => 'date', 40 | 'Desk Calculator' => 'dc', 41 | 'Convert and copy a file, clone disks' => 'dd', 42 | 'Declare variable & set attributes' => 'declare', 43 | 'Set preferences, show hidden files' => 'defaults', 44 | 'Display free disk space' => 'df', 45 | 'Display the differences between two files' => 'diff', 46 | 'Show differences among three files' => 'diff3', 47 | 'DNS lookup' => 'dig', 48 | 'Convert a full pathname to just a path' => 'dirname', 49 | 'Display list of remembered directories' => 'dirs', 50 | 'Disk utilities - Format, Verify, Repair' => 'diskutil', 51 | 'Unbind a job from the current login session' => 'disown', 52 | 'Copy files and folders' => 'ditto', 53 | 'Remove dot-underscore files' => 'dot_clean', 54 | 'Interact with CD/DVD burners' => 'drutil', 55 | 'Query or flush the Directory Service/DNS cache' => 'dscacheutil', 56 | 'Edit, create, manipulate, or delete groups' => 'dseditgroup', 57 | 'Enable root access' => 'dsenableroot', 58 | 'View user and groups rights' => 'dsmemberutil', 59 | 'Directory Service command line utility' => 'dscl', 60 | 'Estimate file space usage' => 'du', 61 | 'Display text on screen' => 'echo', 62 | 'A line-oriented text editor (edlin)' => 'ed', 63 | 'Enable and disable builtin shell commands' => 'enable', 64 | 'List or Set environment variables' => 'env', 65 | 'Evaluate several commands/arguments' => 'eval', 66 | 'Execute a command' => 'exec', 67 | 'Exit the shell' => 'exit', 68 | 'Convert tabs to spaces' => 'expand', 69 | 'Programmed dialogue with interactive programs' => 'expect', 70 | 'Set an environment variable' => 'export', 71 | 'Evaluate expressions' => 'expr', 72 | 'Fix command (history)' => 'fc', 73 | 'Partition table manipulator for Darwin UFS/HFS/DOS' => 'fdisk', 74 | 'Send job to foreground' => 'fg', 75 | 'Determine file type' => 'file', 76 | 'Search for files that meet a desired criteria' => 'find', 77 | 'Reformat paragraph text' => 'fmt', 78 | 'Wrap text to fit a specified width' => 'fold', 79 | 'Loop command' => 'for', 80 | 'Filesystem consistency check and repair' => 'fsck', 81 | 'Filesystem enable/disable ACL support' => 'fsaclctl', 82 | 'Filesystem usage (process/pathname)' => 'fs_usage', 83 | 'Internet file transfer program' => 'ftp', 84 | 'Define Function Macros' => 'function', 85 | 'Get attributes of HFS+ files' => 'GetFileInfo', 86 | 'Parse positional parameters' => 'getopt', 87 | 'Parse positional parameters' => 'getopts', 88 | 'Jump to label and continue execution' => 'goto', 89 | 'Search file(s) for lines that match a given pattern' => 'grep', 90 | 'Print group names a user is in' => 'groups', 91 | 'Compress or decompress files' => 'gzip', 92 | 'Stop and restart the operating system' => 'halt', 93 | 'Refresh the cached/remembered location of commands' => 'hash', 94 | 'Display the first lines of a file' => 'head', 95 | 'Manipulate iso disk images' => 'hdiutil', 96 | 'Command History' => 'history', 97 | 'Print or set system name' => 'hostname', 98 | 'Convert the character set of a file' => 'iconv', 99 | 'Print user and group names/id\'s' => 'id', 100 | 'Conditionally perform a command' => 'if', 101 | 'Configure network interface parameters' => 'ifconfig', 102 | 'View and control IP configuration state' => 'ipconfig', 103 | 'Help info' => 'info', 104 | 'Copy files and set attributes' => 'install', 105 | 'List active jobs' => 'jobs', 106 | 'Join lines on a common field' => 'join', 107 | 'List kernel extensions' => 'kextfind', 108 | 'Configure Apple Remote Desktop' => 'kickstart', 109 | 'Stop a process from running' => 'kill', 110 | 'List files in long format (ls -l)' => 'l', 111 | 'Indicate last logins of users and ttys' => 'last', 112 | 'Load or unload daemons/agents' => 'launchctl', 113 | 'List files in long format, showing invisible files (ls -la)' => 'll', 114 | 'Display output one screen at a time' => 'less', 115 | 'Evaluate expression' => 'let', 116 | 'Convert a universal binary' => 'lipo', 117 | 'Make links between files (hard links, symbolic links)' => 'ln', 118 | 'Set a local (function) variable' => 'local', 119 | 'Find files' => 'locate', 120 | 'Print current login name' => 'logname', 121 | 'log into the computer' => 'login', 122 | 'Exit a login shell (bye)' => 'logout', 123 | 'Display lines beginning with a given string' => 'look', 124 | 'Print files' => 'lpr', 125 | 'Remove jobs from the print queue' => 'lprm', 126 | 'Printer status information' => 'lpstat', 127 | 'List information about file(s)' => 'ls', 128 | 'Reset the Launch Services database' => 'lsregister', 129 | 'List a bill of materials file' => 'lsbom', 130 | 'List open files' => 'lsof', 131 | 'Help manual' => 'man', 132 | 'Spotlight search' => 'mdfind', 133 | 'Manage Spotlight metadata store' => 'mdutil', 134 | 'Create new folder(s)' => 'mkdir', 135 | 'Make FIFOs (named pipes)' => 'mkfifo', 136 | 'Display output one screen at a time' => 'more', 137 | 'Mount a file system' => 'mount', 138 | 'Move or rename files or directories' => 'mv', 139 | 'Simple text editor' => 'nano', 140 | 'Manage network resources' => 'net', 141 | 'Show network status' => 'netstat', 142 | 'Network and System Preferences' => 'networksetup', 143 | 'Set the priority of a command' => 'nice', 144 | 'Run a command immune to hangups' => 'nohup', 145 | 'NTFS file system utility' => 'ntfs.util', 146 | 'Control the action of a shell interrupt' => 'onintr', 147 | 'Open a file/folder/URL/Application' => 'open', 148 | 'Snoop file opens as they occur' => 'opensnoop', 149 | 'Compile Applescript' => 'osacompile', 150 | 'Execute AppleScript' => 'osascript', 151 | 'Modify a user password' => 'passwd', 152 | 'Merge lines of files' => 'paste', 153 | 'Copy data to the clipboard' => 'pbcopy', 154 | 'Paste data from the Clipboard' => 'pbpaste', 155 | 'Test a network connection' => 'ping', 156 | 'Query and manipulate installed packages' => 'pkgutil', 157 | 'Property list utility' => 'plutil', 158 | 'Power Management settings' => 'pmset', 159 | 'Restore the previous value of the current directory' => 'popd', 160 | 'Convert text files for printing' => 'pr', 161 | 'List environment variables' => 'printenv', 162 | 'Format and print data' => 'printf', 163 | 'Process status' => 'ps', 164 | 'Save and then change the current directory' => 'pushd', 165 | 'Print Working Directory' => 'pwd', 166 | 'Display disk usage and limits' => 'quota', 167 | 'Copy files between machines' => 'rcp', 168 | 'Read one line from standard input' => 'read', 169 | 'Mark a variable or function as read-only' => 'readonly', 170 | 'Stop and restart the system' => 'reboot', 171 | 'Exit a function' => 'return', 172 | 'Reverse lines of a file' => 'rev', 173 | 'Remove files' => 'rm', 174 | 'Remove folder(s)' => 'rmdir', 175 | 'Remote Package Manager' => 'rpm', 176 | 'Remote file copy - Sync file tree (also RsyncX)' => 'rsync', 177 | 'Convert text to audible speech' => 'say', 178 | 'Multiplex terminal, run remote shells via ssh' => 'screen', 179 | 'Capture screen image to file or disk' => 'screencapture', 180 | 'Manage system configuration parameters' => 'scutil', 181 | 'Merge two files interactively' => 'sdiff', 182 | 'Administer Keychains, keys, certificates and the Security framework' => 'security', 183 | 'Stream Editor' => 'sed', 184 | 'Generate a list of items' => 'select', 185 | 'Set a shell variable = value' => 'set', 186 | 'Set attributes of HFS+ files' => 'setfile', 187 | 'Print or Check SHA Checksums' => 'shasum', 188 | 'Shift positional parameters' => 'shift', 189 | 'Set shell options' => 'shopt', 190 | 'Shutdown or restart OS X' => 'shutdown', 191 | 'Scriptable image processing system' => 'sips', 192 | 'Delay for a specified time' => 'sleep', 193 | 'System software update tool' => 'softwareupdate', 194 | 'Sort text files' => 'sort', 195 | 'Execute commands from a file' => 'source', 196 | 'Split a file into fixed-size pieces' => 'split', 197 | 'Display the status of a file' => 'stat', 198 | 'Stop a job or process' => 'stop', 199 | 'Substitute user identity' => 'su', 200 | 'Execute a command as another user' => 'sudo', 201 | 'Print a checksum for a file' => 'sum', 202 | 'Suspend execution of this shell' => 'suspend', 203 | 'Print Mac OS X operating system version' => 'sw_vers', 204 | 'Report system configuration' => 'system_profiler', 205 | 'Computer and display system settings' => 'systemsetup', 206 | 'Output the last part of files' => 'tail', 207 | 'Tape ARchiver' => 'tar', 208 | 'Dump traffic on a network' => 'tcpdump', 209 | 'Redirect output to multiple files' => 'tee', 210 | 'Condition evaluation' => 'test', 211 | 'Manipulate text files in various formats (Doc,html,rtf)' => 'textutil', 212 | 'Measure Program Resource Use' => 'time', 213 | 'Print shell & shell process times' => 'times', 214 | 'Time Machine utility' => 'tmutil', 215 | 'Display process information' => 'top', 216 | 'Change file timestamps' => 'touch', 217 | 'Translate, squeeze, and/or delete characters' => 'tr', 218 | 'Execute a command when the shell receives a signal' => 'trap', 219 | 'Trace Route to Host' => 'traceroute', 220 | 'Do nothing, successfully' => 'true', 221 | 'Print filename of terminal on stdin' => 'tty', 222 | 'Describe a command' => 'type', 223 | 'ufs.util' => 'Mount/unmount UFS file system', 224 | 'Limit the use of system-wide resources' => 'ulimit', 225 | 'Users file creation mask' => 'umask', 226 | 'Unmount a device' => 'umount', 227 | 'Remove an alias' => 'unalias', 228 | 'Print system information' => 'uname', 229 | 'Convert spaces to tabs' => 'unexpand', 230 | 'Uniquify files' => 'uniq', 231 | 'Convert units from one scale to another' => 'units', 232 | 'Remove variable or function names' => 'unset', 233 | 'Loop command' => 'until', 234 | 'Show how long system has been running' => 'uptime', 235 | 'Print login names of users currently logged in' => 'users', 236 | 'Encode a binary file' => 'uuencode', 237 | 'Decode a file created by uuencode' => 'uudecode', 238 | 'Generate a Unique ID (UUID/GUID)' => 'uuidgen', 239 | 'Unix to Unix copy' => 'uucp', 240 | 'Text Editor' => 'vi', 241 | 'Wait for a process to complete' => 'wait', 242 | 'Print byte, word, and line counts' => 'wc', 243 | 'Search the whatis database for complete words' => 'whatis', 244 | 'Locate a program' => 'whereis', 245 | 'Locate a program file in the user\'s path' => 'which', 246 | 'Loop command' => 'while', 247 | 'Print all usernames currently logged on' => 'who', 248 | 'Print the current user id and name (`id -un`)' => 'whoami', 249 | 'Send a message to another user' => 'write', 250 | 'Execute utility - passing arguments' => 'xargs', 251 | 'Display and manipulate extended attributes' => 'xattr', 252 | 'Print a string until interrupted' => 'yes', 253 | 'Package and compress (archive) files.' => 'zip', 254 | 'Run the last command again' => '!!' 255 | } 256 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnestor/alfred-terminal-commands/b194cac7775904e93c42a33474ff4b7d998c98fd/icon.png -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | com.gnestor.alfred-terminal-commands 7 | category 8 | Productivity 9 | connections 10 | 11 | 48F47C79-01A7-4C1D-8239-1DAF1D54F7E6 12 | 13 | 14 | destinationuid 15 | 2404AE08-D4CF-4265-B7BB-44043DD356DD 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | 21 | 22 | 23 | createdby 24 | Grant Nestor 25 | description 26 | Search OS X terminal commands 27 | disabled 28 | 29 | name 30 | Terminal commands 31 | objects 32 | 33 | 34 | config 35 | 36 | argumenttype 37 | 1 38 | escaping 39 | 36 40 | keyword 41 | cmd 42 | runningsubtext 43 | Loading results... 44 | script 45 | ruby script.rb "{query}" 46 | title 47 | Search terminal commands 48 | type 49 | 0 50 | withspace 51 | 52 | 53 | type 54 | alfred.workflow.input.scriptfilter 55 | uid 56 | 48F47C79-01A7-4C1D-8239-1DAF1D54F7E6 57 | version 58 | 0 59 | 60 | 61 | config 62 | 63 | autopaste 64 | 65 | clipboardtext 66 | {query} 67 | 68 | type 69 | alfred.workflow.output.clipboard 70 | uid 71 | 2404AE08-D4CF-4265-B7BB-44043DD356DD 72 | version 73 | 0 74 | 75 | 76 | readme 77 | Search OS X Terminal commands using Alfred 2: 78 | 79 | Use this workflow to search OS X Terminal commands by keyword and paste the command into Terminal. 80 | 81 | Usage: 82 | 83 | Type `cmd [keyword]` (or set your own shortcut) to search available terminal commands. Press `ENTER` to copy the command to the clipboard and paste it in the front-most app (e.g. Terminal). 84 | 85 | Install: 86 | 87 | Clone this repo and double-click the `alfred-terminal-commands.workflow` file. 88 | uidata 89 | 90 | 2404AE08-D4CF-4265-B7BB-44043DD356DD 91 | 92 | ypos 93 | 70 94 | 95 | 48F47C79-01A7-4C1D-8239-1DAF1D54F7E6 96 | 97 | ypos 98 | 70 99 | 100 | 101 | webaddress 102 | https://github.com/gnestor/alfred-terminal-commands 103 | 104 | 105 | -------------------------------------------------------------------------------- /package/alfred-terminal-commands.alfredworkflow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnestor/alfred-terminal-commands/b194cac7775904e93c42a33474ff4b7d998c98fd/package/alfred-terminal-commands.alfredworkflow -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnestor/alfred-terminal-commands/b194cac7775904e93c42a33474ff4b7d998c98fd/screenshot.png -------------------------------------------------------------------------------- /script.rb: -------------------------------------------------------------------------------- 1 | require './commands' 2 | # require './related_words' 3 | 4 | def item_xml(options = {}) 5 | <<-ITEM 6 | 7 | #{options[:title]} 8 | #{options[:subtitle]} 9 | 10 | ITEM 11 | end 12 | 13 | def match?(word, query) 14 | word.match(/#{query}/i) 15 | end 16 | 17 | query = Regexp.escape(ARGV.first).delete('>') 18 | 19 | # matches = RELATED_WORDS.select { |k, v| match?(k, query) || v.any? { |r| match?(r, query) } } 20 | matches = COMMANDS.select { |k, v| match?(k, query) || match?(v, query) } 21 | 22 | # 1.8.7 returns a [['key', 'value']] instead of a Hash. 23 | # matches = matches.respond_to?(:keys) ? matches.keys : matches.map(&:first) 24 | 25 | items = matches.sort.map do |key, value| 26 | title = "#{value}: #{key}" 27 | arg = ARGV.size > 1 ? COMMANDS.fetch(key, command) : value 28 | item_xml({ :arg => arg, :uid => value, :title => title, 29 | :subtitle => "Copy #{arg} to clipboard" }) 30 | end.join 31 | 32 | output = "\n\n#{items}" 33 | 34 | puts output 35 | --------------------------------------------------------------------------------