Operations 5 min read

Master iTerm2 on macOS: Custom Shortcuts, Minimalist Prompt, and Secure Dotfile Management

This guide shows how to configure iTerm2 on macOS with custom Ctrl‑arrow shortcuts, set up a minimalist Bash prompt that displays Kubernetes context via kubectx, and manage secure dotfiles using Makefiles, Ansible Vault, and a Docker‑based decryption container for reproducible environments.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master iTerm2 on macOS: Custom Shortcuts, Minimalist Prompt, and Secure Dotfile Management

iTerm2 custom word‑jump shortcuts

Configure iTerm2 to send the traditional Emacs‑style word‑movement escape sequences. In Preferences → Profiles → Your Profile → Keys add two key mappings:

Keyboard shortcut: Ctrl+← Action: Send Escape sequence Esc+: b Keyboard shortcut: Ctrl+→ Action: Send Escape sequence Esc+:

f

Minimal Bash prompt with Kubernetes context

A simple one‑line PS1 such as username@host cwd $ keeps the prompt clean. The current Kubernetes context is shown by the external tool kubectx, which updates the terminal title or can be incorporated into PS1. For inline display of context and namespace, the kube-ps1 script can be used.

Dotfile management with Makefiles and Ansible Vault

All macOS configuration files are stored in a Git repository. Deployment is driven by a set of Makefiles that pull the repository and apply the files. Sensitive data (SSH keys, credentials, etc.) are encrypted with Ansible Vault and kept in the same repository.

To avoid installing Ansible Vault on the host, the decryption step runs inside a Docker container. Typical commands:

# Decrypt secrets and apply dotfiles
make

# Remove generated files and clean the environment
make clean

The Makefile invokes the Docker container, mounts the repository, runs ansible-vault decrypt, and then copies the resulting configuration files to the appropriate locations.

Reproducible terminal environment

By combining iTerm2 key bindings, a minimalist prompt that surfaces Kubernetes context, and a Docker‑based Ansible Vault workflow for dotfiles, the setup provides a portable and reproducible terminal configuration suitable for personal use and SRE workflows.

SREmacOSkubectxiTerm2dotfilesAnsible Vault
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.