Skip to content

Instantly share code, notes, and snippets.

@FanchenBao
Last active November 29, 2024 01:35
Show Gist options
  • Save FanchenBao/046a0ca0a072115b3608a8d9419b432f to your computer and use it in GitHub Desktop.
Save FanchenBao/046a0ca0a072115b3608a8d9419b432f to your computer and use it in GitHub Desktop.
iTerm2 and Oh My Zsh Setup
# If you come from bash you might have to change your $PATH.
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
# for homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
# Path to your oh-my-zsh installation.
export ZSH="/Users/fanchenbao/.oh-my-zsh"
# For LaTex
export PATH=/Library/TeX/texbin:$PATH
# For Go
export PATH=/usr/local/go:/usr/local/go/bin:$HOME/go/bin:$PATH
# Configure ANDROID_HOME env variable
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
# Set default editor
export EDITOR='vim'
# To allow multiprocessing in pytest (see `rc_proc` in Mobintel/gathererPusher/tests/test_remote_control.py)
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
# For fastlane
alias fl="bundle exec fastlane"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Prevent install packages to system python
export PIP_REQUIRE_VIRTUALENV=true
# For tmux where the config is stored at $XDG_CONFIG_HOME/tmux/tmux.conf
export XDG_CONFIG_HOME="$HOME/.config"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
chucknorris
sublime
dircycle
dirpersist
history-substring-search
colorize
zsh-syntax-highlighting)
cowsay -$(gshuf -e b d g p s t w y " " -n 1) -f $(for i in $(cowsay -l); do echo $i; done | tail -n +5 | gshuf -n 1) $(fortune)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# pyenv-virtualenv
eval "$(pyenv virtualenv-init -)"
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/fanchenbao/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/fanchenbao/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/fanchenbao/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/fanchenbao/google-cloud-sdk/completion.zsh.inc'; fi
# Handle the problem of neovim not picking up virtualenv set up by pyenv
# Shamelessly copied from https://vi.stackexchange.com/a/34996/49997
function nvimvenv {
if [[ -e "$VIRTUAL_ENV" && -f "$VIRTUAL_ENV/bin/activate" ]]; then
source "$VIRTUAL_ENV/bin/activate"
command nvim "$@"
deactivate
else
command nvim "$@"
fi
}
alias nvim=nvimvenv
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Run $codelldb to start up a server for debugging C++. You should run this
# command in a separate tmux window
# See https://www.reddit.com/r/neovim/comments/txfy9z/codelldb_configuration_for_nvimdap/
alias codelldb="while sleep 1; do $HOME/.local/share/nvim/mason/bin/codelldb --port 13000; done"

Introduction

The files contained in this gist provides a basic and personal setup for using Oh My Zsh with iTerm2.

Usage

  • Copy the content of .zshrc to ~/.zshrc. Note that the pyenv section can be messy and requires reference back to its documentation.
  • Open iTerm2's preferences and import fanchen.itermkeymap to the "Keys" tab.
  • In iTerm2's preferences, go to Profiles -> Keys, and remove the key mapping for ⌥← and ⌥→.
  • brew install cowsay fortune coreutils zsh-syntax-highlighting pyenv pyenv-virtualenv
{"Touch Bar Items":[],"Key Mappings":{"0xf702-0x320000":{"Text":"","Action":33},"0xf702-0x300000":{"Text":"0x01","Action":11},"0xf703-0x320000":{"Text":"","Action":34},"0xf703-0x300000":{"Text":"0x05","Action":11},"0xf702-0x2a0000":{"Text":"1","Action":47},"0xf72b-0x100000":{"Action":4,"Text":""},"0xf703-0x280000":{"Text":"f","Action":10},"0xf702-0x280000":{"Text":"b","Action":10},"0xf72c-0x100000":{"Action":9,"Text":""},"0xf702-0x220000":{"Text":"0","Action":47},"0xf700-0x300000":{"Action":7,"Text":""},"0xf72d-0x100000":{"Action":8,"Text":""},"0x9-0x40000":{"Action":32,"Text":""},"0xf701-0x300000":{"Action":6,"Text":""},"0xf703-0x220000":{"Text":"0","Action":46},"0xf703-0x2a0000":{"Text":"1","Action":46},"0x19-0x60000":{"Action":39,"Text":""},"0xf729-0x100000":{"Action":5,"Text":""},"0xf72c-0x20000":{"Action":9,"Text":""},"0xf72d-0x20000":{"Action":8,"Text":""}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment