2020-08-08

cot command

CotEditor has 'cot' command-line tool which allows you to control CotEditor from the command-line. To use cot command, install it at first.

Installation

You can install the cot command-line tool to a desired location creating a symbolic link via Terminal. The cot substance is bundled at 'Contents/SharedSupport/bin/cot' in CotEditor.app (We recommend to create it at '/usr/local/bin/').

ln -s /Applications/CotEditor.app/Contents/SharedSupport/bin/cot /usr/local/bin/cot

And uninstallation via Terminal is like the following:

unlink /usr/local/bin/cot

Security authorization on Mojave and later

From macOS 10.14 Mojave, user authorization is required to control CotEditor from other applications in which cot command is used. The authorization is normally done via a dialog displays automatically when you use the cot command for the first time. However, in some cases, you may need to authorize it manually from System Preferences > Security & Privacy > Privacy > Automation. Select the checkbox for CotEditor(and also System Events for --wait option) under your client application, such as Terminal.

Options

The following options can be used on cot command.

| -w, --wait | Wait for opened file to be closed before returning to a prompt. |
| -n, --new | Create a new blank document. |
| -l, --line | Jump to specific line in opened document. is an integer specifying the number of line. |
| -c, --column | Jump to specific column in opened document. is an integer specifying the number of column. |
| -b, --background | Do not bring the application to the foreground. |
| -h, --help | Show help. |
| -v, --version | Print version information. |

For --line and --column options, you can specifty a negative number to count from the end of the document (--line option) or a line (--column option).

Examples

A simple cot command will launch CotEditor, or just activate it if CotEditor is already running.

cot

The following command opens the foo.txt file on CotEditor and move the cursor to the line 200 in the opened document. cot command do nothing if foo.txt file is not exists.

cot --line 200 foo.txt

The following command opens the foo.txt file on CotEditor and move the cursor to the end of the document.

cot --line -1 --column -1 foo.txt

You can also pipe a text. CotEditor will open a new document with the piped text.

echo "I am a dog but also a cow at the same time." | cot

Using --wait option, CotEditor can be used as the editor for git.

git config --global core.editor "cot -w"

See Also

  • Integration preferences

你可能感兴趣的:(linux,docker,python,macos,centos)