Skip to content

Instantly share code, notes, and snippets.

@kbristow
Last active March 7, 2025 10:43
Show Gist options
  • Select an option

  • Save kbristow/2886ffba1f0d0178dfce9ec64af97d84 to your computer and use it in GitHub Desktop.

Select an option

Save kbristow/2886ffba1f0d0178dfce9ec64af97d84 to your computer and use it in GitHub Desktop.
iTerm Setup

How to configure iTerm

PreRequisites

  • Install iTerm brew install --cask iterm2
  • Install font (may not be required depending on theme used) brew tap homebrew/cask-fonts && brew install --cask font-source-code-pro

Setup Prezto

Install

git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

Create ~/.zshrc

setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
    ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
  done

Add modules to ~/.zpreztorc

zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'git' \
  'syntax-highlighting' \
  'history-substring-search' \
  'prompt'

Select and set a theme. Can view themes using prompt -l. Can set theme/see theme setting instructions by running prompt -s theme-name. Some nice themes:

  • powerlevel10k
  • powerline
  • minimal

Likely have to set the name of theme in the ~/.zprestorc file

Setup dotfolder and zshrc

Create a dotfile folder

mkdir ~/dotfiles

Add ~/dotfiles/env.sh with below contents (do whatever modifications you want here):

export EDITOR=code

# File search functions
function f() { find . -iname "*$1*" ${@:2} }
function r() { grep "$1" ${@:2} -R . }

# Create a folder and move into it in one command
function mkcd() { mkdir -p "$@" && cd "$_"; }

# Aliases
alias g='git'
alias l='ls'

Add the following to fix zsh key bindings at ~/dotfiles/fix_zsh_keys.sh

#!/usr/bin/env zsh

# https://stackoverflow.com/a/29403520/1092815

# forward-word/backward-word change
# https://stackoverflow.com/a/16411270
bindkey -e
bindkey '[C' forward-word
bindkey '[D' backward-word

# may need this instead of the above two lines if they do not work
# bindkey "\e\e[D" backward-word 
# bindkey "\e\e[C" forward-word

# changes hex 0x15 to delete everything to the left of the cursor,
# rather than the whole line
bindkey "^U" backward-kill-line

# binds hex 0x18 0x7f with deleting everything to the left of the cursor
bindkey "^X\\x7f" backward-kill-line

# adds redo
bindkey "^X^_" redo

Setup iTerm

Download the Clovis-iTerm2 theme. Once downloaded, extract and double click it to import it into iTerm. Then go to the default profile and select the clovis theme.

Setup the keybindings to work for word deletion and skip, and line deletion and skip following the instructions at iterm2-macos-dynamic-profile.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment