Oh My ZSH
Zsh?¶
Oh My Zsh is a framework for Zsh, the Z shell.
- In order for Oh My Zsh to work, Zsh must be installed.
- Please run
zsh --version
to confirm. - Expected result:
zsh 5.0.8
or more recent - Additionally, Zsh should be set as your default shell.
- Please run
echo $SHELL
from a new terminal to confirm. - Expected result:
/usr/bin/zsh
or similar
Install and set up zsh as default¶
If necessary, follow these steps to install Zsh:
-
There are two main ways to install Zsh:
-
With the package manager of your choice, e.g.
sudo apt install zsh
(see below for more examples) -
From source, following the instructions from the Zsh FAQ.
-
Verify installation by running
zsh --version
. Expected result:zsh 5.0.8
or more recent. -
Make it your default shell:
chsh -s $(which zsh)
or usesudo lchsh $USER
if you are on Fedora. -
Note that this will not work if Zsh is not in your authorized shells list (
/etc/shells
) or if you don't have permission to usechsh
. If that's the case you'll need to use a different procedure.- If you use
lchsh
you need to type/bin/zsh
to make it your default shell.
- If you use
-
Log out and log back in again to use your new default shell.
-
Test that it worked with
echo $SHELL
. Expected result:/bin/zsh
or similar. -
Test with
$SHELL --version
. Expected result: 'zsh 5.8' or similar
How to install zsh on many platforms¶
macOS¶
Try zsh --version
before installing it from Homebrew. Preferably newer than or equal to 5.0.8
.
To set zsh as your default shell, execute the following assuming a default install of Homebrew
- Recent macOS versions:
For m1 macs:
For intel macs:
- macOS High Sierra and older:
Assuming you have Homebrew installed. If not, most versions of macOS ship zsh by default, but it's normally an older version. Alternatively, you may also use MacPorts
Ubuntu, Debian & derivatives (Windows 10 WSL | Native Linux kernel with Windows 10 build 1903)¶
If you don't have apt
, the recommended package manager for end users
[1]
[2]
[3]
[4]
, you can try apt-get
or aptitude
.
Other distributions that apply include: Linux Mint, elementary OS, Zorin OS, Raspbian, MX Linux, Deepin.
OpenSUSE¶
Arch Linux or Manjaro¶
Void Linux¶
Fedora¶
OpenBSD¶
To install the package:
FreeBSD¶
To install the package:
To install the port:
To reduce memory usage, optionally enable zsh-mem options with
before running "make install".
Centos/RHEL¶
Cygwin¶
Install the zsh package using the installer. Unfortunately Cygwin doesn't have a standard command line interface. You could, however, setup apt-cyg and install zsh as follows:
The easiest way to change the default shell is to set your SHELL user environment variable. Search for "Edit Environment variables for your account" to bring up the environment variables window, create a new variable named "SHELL" and give it the value "/usr/bin/zsh/".
Alternatively: Open Cygwin (in BASH) then type:
Once the .bashrc file is open, add this line to the very top:
Close and save the file. Close and reopen Cygwin. It will execute the command every time you load the terminal and run your zsh shell.
Solus¶
Funtoo/Gentoo¶
Alpine Linux¶
MSYS2¶
Termux (Android)¶
Termux is an terminal emulator for Android but has modern feature like Debian and Ubuntu (Termux has Bash shell and Busybox GNU-like programs). For the package manager, Termux using an Debian/Ubuntu package manager, APT. To install the package, run this command:
The command looks like FreeBSD package manager (pkg
). Or you can run this command:
To set zsh as your default shell, run this command:
Oh My Zsh¶
Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.
- You'll need
zsh
to install Oh My Zsh. Runzsh --version
to check if you have it:
- If you see
command not found
you don't have zsh installed. See Installing Zsh for instructions. - Once you have zsh, you can install Oh My Zsh by simply running one of these commands:
Method | Command |
---|---|
curl | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
wget | sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
fetch | sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
NOTE: the installer will rename an existing .zshrc
file to .zshrc.pre-oh-my-zsh
.
Cheatsheet¶
Quick reference:
- Oh My Zsh's Command-Line Interface (CLI):
omz
. Runomz --help
for available commands. - To update Oh My Zsh:
omz update
. - To uninstall it:
uninstall_oh_my_zsh
. - To apply changes made to
.zshrc
:omz reload
(this just runsexec zsh
). Do NOT runsource ~/.zshrc
.
Commands¶
Command | Description |
---|---|
alias |
List all aliases |
mkcd |
Create a new directory and change to it, will create intermediate directories as required. |
take |
Like mkcd , but also knows how to handle remote URLs. When given an argument that looks like a URL (something that ends in .git or .tar.(gz\|bz2\|xz) ), download the remote resource and extract it (if necessary) into the current directory. Then change to the newly extracted/downloaded/cloned directory. |
zsh_stats |
Get a list of the top 20 commands and how many times they have been run. |
Directory¶
Alias | Command |
---|---|
md |
mkdir -p |
rd |
rmdir |
cd / ~ |
cd to your home directory |
.. |
cd .. |
... |
cd .. |
.... |
cd .. |
..... |
cd .. |
/ |
cd / |
d |
dirs -v (lists last visited directories) |
cd +n |
Switch to directory number n |
- |
cd to last visited directory |
1 |
cd -1 |
2 |
cd -2 |
3 |
cd -3 |
4 |
cd -4 |
5 |
cd -5 |
6 |
cd -6 |
7 |
cd -7 |
8 |
cd -8 |
9 |
cd -9 |