Low Orbit Flux Logo 2 D

zshrc

The .zshrc file contains variables, key bindings, aliases, and functions. It is sourced for interactive shells. it is kind of similar to .zshenv, .zprofile, and .zlogin.

Zsh is a popular shell on Linux, Mac OSX, and other systems.

Where is the .zshrc file on Mac?

The zshrc file can be found here ~/.zshrc. In some cases it will already exist and in other cases you will need to create it. People have reported that it doesn’t exist until they create it.

Note that ~ refers to your home directory. Since the file begins with a dot “.” it is hidden by default. You can view it using the terminal with the following commands.

Show everything in your home directory including your zshrc file:


ls -la ~

View your zshrc file:


cat ~/.zshrc

You can create it like this:


nano ~/.zshrc

Once you have done this you can place whatever zsh settings you want in this file.

Setup on Ubuntu Linux

I installed zsh on my Ubuntu Linux system with the following command:


sudo apt install zsh

I was given the following options upon running the shell for the first time:


This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

(2)  Populate your ~/.zshrc with the configuration recommended
     by the system administrator and exit (you will need to edit
     the file by hand, if so desired).

--- Type one of the keys in parentheses --- 2

This generated the following .zshrc file for me:


user1@zippy-zap ~ % cat .zshrc
# Set up the prompt

autoload -Uz promptinit
promptinit
prompt adam1

setopt histignorealldups sharehistory

# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e

# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history

# Use modern completion system
autoload -Uz compinit
compinit

zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true

zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'