今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

Quickly open the command line

Quick Open Command Line#

As a developer who frequently uses Mac, there is often a need to quickly open the command line in the Finder folder and enter the current folder. And if you use Xcode, there is usually another requirement to quickly open the command line in Xcode and enter the current project.

Ps: The command line tool demonstrated below uses Warp, but the system's Terminal also supports it.

Quickly Open Command Line in Finder Folder#

Open System Preferences, find Keyboard, and then click Keyboard Shortcuts, as shown in the figure below:

finderOpenTerminal

Then find Services, expand Files and Folders, check Open folder with Warp, double-click on the position of none on the right side, enter the shortcut key, and then click Done. From now on, you can quickly open Warp using this shortcut key, as shown in the figure below:

finderOpenTerminal2

Open any folder in Finder, and then press the shortcut key you just entered. You will find that Warp is quickly launched from the current directory and enters the current folder.

Quickly Open Command Line in Xcode#

To quickly open the command line in Xcode, you can use Awesome-Xcode-Behaviors.

  1. First, download Awesome-Xcode-Behaviors and unzip it to a specified folder.
  2. Then enter this folder and authorize chmod -R +x "Pods/" "Gem/" "Open Application/" to execute.
  3. Open Xcode settings, select the Behaviors tab, click the + button in the bottom Custom section, enter the name of this Behavior on the left, and then double-click the CMD after the name to set the shortcut key that triggers this Behavior. Scroll to the bottom right, check Run, and then click Choose Script to select the unzipped Awesome-Xcode-Behaviors, as shown in the figure below:
    quickOpenTerminal3
  4. Open any project, and then trigger the shortcut key you just set to directly open the command line from the current directory.

Ps:

After downloading and unzipping Awesome-Xcode-Behaviors, you can see its contents. Among them, Open Application is used to quickly open applications. You can see that it supports quickly opening iTerm, Terminal, and others. You can also customize it yourself. open-warp.sh is added by yourself. The other folders are for other quick commands. The Carthage folder contains carthage archive, carthage clean, and others. The Gem folder is for gem related operations. The Pods folder is for pod related operations. All of these can be set as shortcut keys for quick execution through Behavior.

quickOpenTermianl4

For example, setting Behavior to quickly trigger pod install and pod update allows you to directly execute pod related operations by simply pressing a shortcut key when adding or modifying Pod libraries, without having to open the command line and enter the relevant commands. This is convenient and efficient.

Reference#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.