Created
January 14, 2020 18:41
-
-
Save jeffjohnson9046/6b4cfe9e129b64b084b3f5afbe776c21 to your computer and use it in GitHub Desktop.
Steps I took to set up my Z shell prompt the way I like
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: These steps assume that zsh is already installed | |
# Download and install iTerm2, which can be found here: https://iterm2.com/downloads/ | |
# Install oh-my-zsh (details and alternate installation instructions can be found here: https://github.com/ohmyzsh/ohmyzsh): | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# Install the Powerlevel9k theme for zsh (details for using the oh-my-zsh installation can be found here: https://github.com/Powerlevel9k/powerlevel9k/wiki/Install-Instructions#option-2-install-for-oh-my-zsh): | |
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k | |
# Update your ~/.zshrc to use the Powerlevel9k theme: | |
vi ~/.zshrc | |
# Add this line to use the theme: | |
ZSH_THEME="powerlevel9k/powerlevel9k" | |
# Install the nerd fonts via homebrew (details can be found here: https://github.com/ryanoasis/nerd-fonts#option-4-homebrew-fonts): | |
brew tap homebrew/cask-fonts | |
brew cask install font-hack-nerd-font | |
# Install a particular font to get the icons (Meslo is chosen here, but there are other fonts): | |
brew cask install font-meslo-nerd-font | |
# In iTerm2, go to Preferences > Profiles > Text and make the following changes: | |
# * For "Font", choose one of the Meslo Nerd fonts (I chose MesloLGLDZ Nerd Font) | |
# * Check the "Use a different font for Non-ASCII text | |
# * For the "Non-ASCII Font", choose the same font as the selection in the "Font" dropdown | |
# Install zsh autosuggest and zsh syntax highlighting plugins (from here: https://gist.github.com/dogrocker/1efb8fd9427779c827058f873b94df95): | |
# in my case, $ZSH_CUSTOM=/Users/jeff.johnson/.oh-my-zsh/custom/ | |
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting | |
# Update your ~/.zshrc to include the auto-suggest and syntax highlighting plugins: | |
vi ~/.zshrc | |
# Find the plugins array in your ~/.zshrc and add zsh-autosuggestions and zsh-syntax-highlighting to the list. An example is shown below: | |
plugins=( | |
git | |
docker | |
jsontools | |
zsh-autosuggestions | |
zsh-syntax-highlighting | |
kube-ps1 | |
) | |
# Customize how directories will appear by adding these lines into your ~/.zshrc: | |
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 | |
POWERLEVEL9K_SHORTEN_DELIMITER="" | |
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' | |
# This makes the directory on the prompt look like this: | |
/./c/t/powerlevel9k | |
# Which is this: | |
pwd | |
/Users/jeff.johnson/.oh-my-zsh/custom/themes/powerlevel9k | |
# --------------------------------------------------------------- | |
# Configure the right-hand prompt to show: | |
# * command status | |
# * current kubectl context | |
# --------------------------------------------------------------- | |
# Add the kube-ps1 plugin to your ~/.zshrc: | |
vi ~/.zshrc | |
# Find the plugins array in your ~/.zshrc and add kube-ps1 to the list. An example is shown below: | |
plugins=( | |
git | |
# other plugins... | |
kube-ps1 | |
) | |
# Configure the prompt (I don't want/need to see the namespace; I just want to see the cluster my current context | |
# is pointed at, configuration details can be found here: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/kube-ps1): | |
POWERLEVEL9K_CUSTOM_KUBE_PS1='kube_ps1' | |
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status custom_kube_ps1) | |
KUBE_PS1_SYMBOL_USE_IMG=true | |
KUBE_PS1_NS_ENABLE=false | |
KUBE_PS1_DIVIDER='' | |
# OPTIONAL: Get some iTerm themes from here: https://iterm2colorschemes.com/ | |
# I like FirefoxDev and Wombat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If everything's wired up right, the prompt should look something like this (I did not include the
k8s
cluster name, but trust me - it's there):