This is the 20th day of my participation in the August More Text Challenge

MacOS Setup shortcut keys to start terminal

In Linux, you’re used to being able to call up terminals anywhere and do simple tasks, like downloading something with aria2C.

Switching to macOS is a hassle. The macOS doesn’t come with a terminal that allows you to quickly open a command-line window by setting shortcuts. But we can do this with “auto action” + “Apple Script”.

Automatic operation

Open Automator. app -> Create a Service.

Add a step to run AppleScript inside:

Fill in the Apple Script:

on run {input, parameters}
	tell application "Terminal"
		set origSettings to default settings
		set default settings to settings set "mine quick"
		do script ""
		activate
		set default settings to origSettings
	end tell
	
	return input
end run
Copy the code

This code does:

  • Let the terminal APP set the default description file
  • Create a new terminal window with the set description file
  • Finally, reset the default description file to its previous default value

Don’t forget to save this automatic operation and give it a name, like New Terminal Window.

If you don’t need the open terminal window to specify a specific description file, delete the three lines of set:

Specific description file

Description files are configurations such as style and what shell to use :(in terminal preferences)

My terminal’s default description file is “Pro”, usually used for work, yours is a pure black, opaque, using bash, very classical:

I also created a custom description file called “Mine Quick”. The main difference with Pro is that it provides a translucent frosted glass effect and uses ZSH. This description file is more modern and fits with the current macOS UI:

(Another point: This mine Quick will improve the transparency of other Windows when they are inactive, that is, after the mouse is clicked on other Windows, so that the contents of lower Windows will not be blocked. In short, this mine Quick is more convenient for quick auxiliary work.)

I want to get a Pro style when doing serious work by manually opening the window from the terminal app icon. However, the terminal window opened by shortcut keys is just for quick and casual use and auxiliary operation. Mine Quick is used to describe the file.

So there is that section that describes the operation of the file.

Set global shortcut keys

Settings -> Keyboard -> Shortcuts -> Services:

reference

  • Cloud.tencent.com/developer/a…
  • Apple.stackexchange.com/questions/1…
  • www.zhihu.com/question/20…