Using Terminal Completion on ITerm2

iTerm2 is a popular terminal emulator for macOS that comes with a variety of features to enhance your command-line experience. One such feature is Terminal Completion, which allows you to quickly and efficiently complete commands, file paths, and more using keyboard shortcuts. In this article, we’ll explore how to use Terminal Completion in iTerm2 using the Cmd + ; shortcut.

What is Terminal Completion?

Terminal Completion, also known as tab completion, is a feature that helps you save time when typing commands in the terminal. It works by automatically suggesting and completing commands, file paths, directory names, and more as you type. This can be especially useful when working with long and complex commands or navigating through a directory structure with many nested folders.

Enabling Terminal Completion in iTerm2

To use Terminal Completion in iTerm2, you first need to ensure that it’s enabled. Follow these steps:

  1. Open iTerm2: Launch iTerm2 from your Applications folder or preferred method of opening the application.

  2. Access Preferences: Click on “iTerm2” in the menu bar at the top of the screen, and then select “Preferences” or use the shortcut Cmd + ,.

  3. Navigate to Profiles: In the Preferences window, select the “Profiles” tab.

  4. Select Your Profile: Choose the profile you want to enable Terminal Completion for. You can create a new profile or modify an existing one.

  5. Edit Profile: Click the “Edit Profiles…” button at the bottom of the Profiles tab.

  6. Enable Terminal Completion: In the Profile settings, go to the “Text” tab.

  7. Check “Enable Terminal Completion”: Under the “Auto-Mark URLs” section, check the box labeled “Enable Terminal Completion.”

  8. Save Profile: Click the “Save” button to save your profile settings.

Terminal Completion is now enabled for the selected profile in iTerm2.

Using Terminal Completion

Once you have enabled Terminal Completion in iTerm2, you can start using it while working in the terminal. Here’s how:

  1. Open iTerm2: Launch iTerm2 and open a terminal window using your selected profile.

  2. Start Typing a Command: Begin typing a command or a file path in the terminal.

  3. Trigger Completion: To trigger Terminal Completion, press the Cmd + ; keyboard shortcut. iTerm2 will attempt to complete the command or path based on what you’ve typed so far.

  4. Cycle Through Suggestions: If iTerm2 provides multiple suggestions, you can cycle through them by pressing Cmd + ; repeatedly until you find the desired completion.

  5. Accept Completion: Once the desired completion is shown, you can accept it by pressing the Tab key. This will replace your partially typed command or path with the completed suggestion.

  6. Execute the Command: After accepting the completion, you can press Enter to execute the command.

Conclusion

Terminal Completion in iTerm2 is a powerful feature that can significantly improve your productivity when working in the terminal. By enabling it and using the Cmd + ; shortcut, you can quickly complete commands, file paths, and more, making your command-line tasks more efficient and less error-prone.

0%