Skip to content

Latest commit

 

History

History
107 lines (74 loc) · 3.24 KB

File metadata and controls

107 lines (74 loc) · 3.24 KB

iTerm2 Configuration

This directory contains iTerm2 preferences that are version-controlled with your dotfiles.

Setup

iTerm2 has been configured to save its preferences to this directory instead of the default location (~/Library/Preferences/).

How it works

  1. Custom Preferences Folder: iTerm2 is set to load/save preferences from this directory
  2. Semantic History: Configured to open files in Neovim using nvr (Neovim Remote)
  3. Tab-specific sockets: Each iTerm tab has its own Neovim server socket

Initial Setup

Run this script to configure iTerm2 preferences location and Semantic History:

# Set iTerm2 to use custom preferences folder
defaults write com.googlecode.iterm2 PrefsCustomFolder -string "$HOME/dotfiles/iterm2"
defaults write com.googlecode.iterm2 LoadPrefsFromCustomFolder -bool true

# Configure Semantic History for all profiles
python3 ~/dotfiles/scripts/setup_iterm_semantic_history.py

After Installation

  1. Restart iTerm2 for changes to take effect
  2. iTerm2 will now save all preferences to ~/dotfiles/iterm2/
  3. Any changes you make in iTerm2 settings will be automatically saved here

Features

Cmd+Click to Open Files in Neovim

The Semantic History feature allows you to Cmd+Click on file paths in your terminal to open them in Neovim.

How it works:

  • Detects patterns like: file.py:42, path/to/file.js:10, etc.
  • Opens the file in the Neovim instance running in the same iTerm tab
  • Each tab has its own Neovim server, so clicks in Tab A only affect Tab A's Neovim

Usage:

  1. Split your iTerm window (⌘D)
  2. In the left pane: start nvim or vim
  3. In the right pane: run commands that output file paths:
    pytest  # Shows test failures with file:line
    python script.py  # Shows stack traces
    echo "Check file.py:42 for the bug"
  4. Cmd+Click on any file path to open it in the left pane's Neovim!

Themes

Color themes are stored in ../iterm-themes/ directory.

Files

  • com.googlecode.iterm2.plist - Main preferences file (auto-generated by iTerm2)
  • README.md - This file

Maintenance

Resetting Configuration

If you need to reset to defaults:

# Remove custom folder setting
defaults delete com.googlecode.iterm2 PrefsCustomFolder
defaults delete com.googlecode.iterm2 LoadPrefsFromCustomFolder

# Restart iTerm2

Updating Semantic History

If you need to update the Semantic History command:

python3 ~/dotfiles/scripts/setup_iterm_semantic_history.py

Edit the script at ~/dotfiles/scripts/setup_iterm_semantic_history.py to change the command.

Troubleshooting

Cmd+Click doesn't work

  1. Verify Neovim is running with a server: ls /tmp/nvimsocket-*
  2. Check that nvr is installed: which nvr
  3. Test manually: nvr --servername /tmp/nvimsocket-<tab-id> --remote test.txt

Changes not persisting

  1. Make sure iTerm2 is reading from the custom folder:
    defaults read com.googlecode.iterm2 LoadPrefsFromCustomFolder
    # Should output: 1
  2. Restart iTerm2

Tab-specific sockets not working

  1. Check that ITERM_SESSION_ID is set: echo $ITERM_SESSION_ID
  2. Verify the nvim function in .zshrc is loaded: type nvim
  3. Run tests: ~/dotfiles/tests/test_nvim_server.sh