今是昨非

今是昨非

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

Open the command line quickly

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, 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 see the command line directly opened from the current directory.

Ps:

After downloading and unzipping Awesome-Xcode-Behaviors, you can see the contents inside. Among them, Open Application refers to quickly opening applications. You can see that it supports quickly opening iTerm, Terminal, etc., or you can customize it yourself. open-warp.sh is the one I added. The other folders are for other quick commands. Under the Carthage folder, there are carthage archive, carthage clean, etc. The Gem folder is for gem related operations, and the Pods folder is for pod related operations. All of these can be set as shortcut keys through Behavior to execute quickly.

quickOpenTermianl4

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

Reference#

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