ホーム 格闘技 Let's set up the command-line tool 'iTerm2'

Let's set up the command-line tool 'iTerm2'

真鍋 千夏 真鍋 千夏 • 更新: • 公開: • 読了約 26 分
目次

I would like to write about the 'Terminal', a command-line tool that is essential for system development.

I don't mean this kind of terminal (lol).

I want to tinker with a 'terminal' in the terminal... just kidding (lol).

I've digressed a bit, my apologies.

First, I have a question.

Are you a Mac user or a Windows user?

By the way, I am a Mac user.

When I was a salaryman (SE / PG), I did system development on Windows, but now that I am a freelance software engineer, I use a Mac for writing and system development.

I've heard from friends in the web industry that a huge number of people are using Macbooks these days.

Maybe it's because it's the web industry...

That friend is an incredibly high-spec, full-stack engineer (frontend and backend engineer) who is very active in the field.

My friend also works on a Macbook and uses the command-line tool I am about to introduce.

Please note that the rest of this article will not be useful for those using Windows.

Terminal

n8206e2163904

In daily programming, the command-line tool I use frequently is the terminal.

If you are on Windows, it would be Command Prompt or PowerShell, I suppose.

Speaking of terminals, it's white text on a black background.

If you have seen the Matrix movies, you probably imagined green text on a black background.

I believe the default setting for recent Macs is black text on a white background.

If you ask me, it's honestly uncool.

I'd say you should at least customize it by changing the font or shell, or making it semi-transparent.

By the way, here is my standard Mac 'Terminal'.

It's too transparent, isn't it?

Don't you want a cooler 'Terminal'?

A friend of mine also said that modern development environments are different starting from the command-line tool.

Let's say goodbye to the pre-installed 'Terminal' today.

Let's use this from today on.

iTerm2

Some companies may prohibit the use of such tools, but I think quite a few people use 'iTerm2' when developing web systems on a Mac, don't they?

I've been using it for about 8 years since I became a freelance software engineer and switched to Mac.

Once you switch, you'll find detailed environment settings and useful features, and the Hotkeys are surprisingly convenient.

I recommend it especially for those who don't have any particular preferences.

My terminal environment uses 'iTerm2' with either the 'z shell (zsh)' or 'fish shell'.

I will write an article about setting up the 'z shell (zsh)' and 'fish shell' environments at a later date.

Download

There are two ways to install it: from the official website or via 'Homebrew', so choose whichever you prefer.

Official Website

Let's download it right away from the official "iTerm2" website.

Once downloaded, place it in the "Applications" folder just like any other app.

After that, right-click and select Open to launch it.

Also, please check "iTerm2" under "Full Disk Access" in "Security & Privacy" within System Preferences.

Homebrew

You can also install it using "homebrew-cask," which allows you to manage GUI apps via package management.

1. Install "Command Line Tools"

$ xcode-select --install

$ xcode-select -version
確認できれば、インストール完了
xcode-select version 2373.

2. Install "Homebrew"

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ brew -v
確認できれば、インストール完了
Homebrew 2.2.11​

Alternatively, please install it from the link below.

3. Install "homebrew-cask"

$ brew install cask

$ brew -v
確認できれば、インストール完了
Homebrew 2.2.11
Homebrew/homebrew-core (git revision 4fb50f; last commit 2020-03-27)
Homebrew/homebrew-cask (git revision b898f; last commit 2020-03-28)​

4. Install "iTerm2"

Use "homebrew-cask" to install "iTerm2".

$ brew cask install iterm2

The installation is now complete.

You can also install various other things like "VS Code," "Docker," and "Sublime Text," so give it a try.

Once the installation is finished, let's try launching "iTerm2".

Simple, right?

Benefits

I have written my thoughts in a bulleted list.

✅️ More feature-rich than the existing terminal
✅️ Requires little effort to set up
✅️ Allows for detailed display and feature configuration
✅️ Supports screen splitting and input auto-completion
✅️ Looks stylish and clean
✅️ Can make windows semi-transparent
✅️ Supports full-screen display
✅️ Allows for detailed key mapping configuration
✅️ Supports HotKey configuration
✅️ Can log terminal input and output

Preferences screen

To open the environment settings, click "Preferences..." from the "iTerm2" menu in the menu bar. (Shortcut key: "command (⌘) + ,")

Unlike the standard terminal, you can see just by looking at these settings that you can customize it in quite a lot of detail.

・General

You can configure basic settings here.

Startup:

Closing:

Magic:

Services:

Selection:

Window:

Preferences:

tmux:

・Appearance

You can configure settings for the appearance, tabs, and windows.

These settings include the display position of the tab bar and status bar, the text displayed in the window, and whether to add a border to the window.

General:

Windows:

Tabs:

Panes:

Dimming:

・Profiles

You can configure more detailed terminal settings.

In Profiles, you can add and manage multiple profiles.

Even more detailed settings are possible, and you can configure specific aspects such as color changes and window display settings here.

General:

Colors:

Text:

Window:

Terminal:

Session:

Keys:

Advanced:

・Keys

You can configure shortcut keys.

In Keys, while we will introduce useful shortcut keys to remember at the end, you can set up or add shortcuts here.

Key Bindings:

Navigation Shortcuts:

Hotkey:

Remap Modifiers:

The following three are unused, so leave them as they are.

・Arrangements

You can configure window layout settings.

・Pointer

You can configure mouse settings and trackpad gestures.

General:

Bindings:

・Advanced

These are advanced settings.

Customization

・Set the Dracula theme

I like the Dracula theme, so I am importing it.

As you can see on the Dracula website, it can be imported into various applications.

Preferences vary from person to person, so feel free to choose what you like.

Please follow the steps to import it.

Configuration method:

・Disable Native full screen windows

When opening "iTerm2", it automatically opens a desktop for iTerm, which prevents it from being displayed in full screen on any desired desktop.

Therefore, we will "disable" this setting.

Configuration method:

・Set new window settings to full screen

Don't forget to configure this as well to set the window to full screen.

Change "Style:" to "Fullscreen".

Change "Screen:" to "Screen with Cursor" so that it displays on the screen where the cursor is currently located.

Change "Space:" to "All Spaces" so that it opens on any Space.

Configuration method:

・Set a HotKey to open it with a shortcut

By pressing the shortcut, you can easily toggle visibility and display it on any desktop.

iTerm2 has a built-in feature to show or hide it via a shortcut, so you just need to enable that setting.

The default is "Option" + "Space", so please set it to your preference.

Since it conflicts with "Alfred 4" for me, I have set it to "Command" + "i".

How to set it up:

・Make the background transparent (Recommended)

When you display "iTerm2" on a desktop where a browser or similar is open, the screen behind it becomes transparent, which improves work efficiency.

It is perfect for practicing commands (copying code) while referring to a browser hidden in the background.

It looks like this. You can see the source code faintly, right?

You can adjust the transparency by moving the "Transparency:" bar left or right.

By the way, you can also toggle between transparent and opaque with "Command" + "u".

How to set it up:

・Hide the menu bar

While it varies from person to person, maximizing your terminal display can improve your work efficiency.

How to configure:

Useful shortcuts to remember

These are useful shortcuts to remember.

・Tab-related

The standard Mac "Terminal" also has a tab feature, but "iTerm2" allows for faster navigation using shortcuts.

・Screen splitting-related

This is a feature not found in the standard Mac "Terminal"; you can split the screen vertically and horizontally.

Unlike tabs, this allows you to work while viewing multiple screens at once.

Until you get used to it, just keep moving back and forth to reach the desired pane.

I think this is useful for web system development using "Docker".

・Input completion (Auto-complete)

By using input completion after typing the first few characters, you can select completion candidates from your input and display history.

You can also perform a filtered search by continuing to type.

It is subtly convenient, so it might be useful to remember.

I use the "fish shell," so I am using its input completion.

・Clipboard

It displays a list of text you have copied and pasted in the past, so I use this often as well.

・Instant Replay

If download processes or execution logs have scrolled by, you can replay and check your terminal operations, and display a seek bar.

It is extremely useful for checking operations and procedures during normal use.

・Open links

You can open URLs, directory paths, and file links.

URLs can be opened in a web browser, directory paths in Finder, and files in a specified editor.

・Search

・Full screen

There are many other detailed features and settings, but since you might get discouraged if you try to learn everything at once, let's gradually master the features you use most often.

Finally, I have listed the shortcuts I use frequently.

Once you learn them, your work efficiency will improve significantly.

If you like, take a screenshot (print it out) and keep it handy.

Frequently used shortcuts

Summary

While there are countless terminal apps out there, "iTerm2" doesn't have any particularly strange quirks, so I think it can be used as an extended version of the standard Mac terminal.

同じカテゴリの記事

真鍋 千夏
デジタルマーケター 真鍋 千夏
プロフィールを見る →

美容と暮らしの話題を担当。メーカーの公式発表、商品成分の公表資料、専門家の監修記事をもとに事実を整理します。

おすすめの関連記事