---
title: Shell configuration
descriptions: empty description
summary: empty summary
#weight: 2
categories:
- Shell
- zsh
tags:
- .zshrc
- oh-my-zsh
- powerlevelk9
- nerdfont
---

# ZSH
I prefer to use ZSH because of its advanced features mainly the easy file name globbing. With [oh my zsh](https://ohmyz.sh/) a good framework for extensions to ZSH exist. The documentation can be found at [GitHub](https://github.com/ohmyzsh/ohmyzsh/wiki). However, the installation practice with directly executing a shell script from GitHub is quite dangerous, as you do not have a trustworthy anchor like signed Linux distribution packages. Hence, I suggest to **review** the [installation script](https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) at least prior to installing. At the very end, the install script asks for changing your users default shell to zsh.

```shell-session
# apt-get install zsh
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

## Configuring oh my zsh
Oh my zsh, is mainly configured through your ``.zshrc`` file.

### Theme and Fonts
I like the [powerlevel9k](https://github.com/Powerlevel9k/powerlevel9k/wiki) theme. It is installed by cloning its GitHub repository into the theme directory
```shell-session
# git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
```
and selecting it as the theme in your ``.zshrc``:
```zsh
ZSH_THEME="powerlevel9k/powerlevel9k"
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(history)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
POWERLEVEL9K_MODE='nerdfont-complete'
```
As you can see, a particular font, i.e. ``nerdfont-complete`` is required. It gives you these nice symbols in shell
![zsh_theme_demo](/client/ohmyzsh_theme_demoprompt.png)
Ther nedfonts can be downloaded from [Nerdfonts.com](https://nerdfonts.com), [GitHub](https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Hack/Regular/complete) or directly [here](/client/nerdfont.zip). The fonts are under MIT license.

To use these fonts, copy the ``*.ttf`` files into ``~/.fonts``. Alternatively, you can install them system-wide by copying them over to ``/usr/loca/share/fonts``. Aferwards, the font can be directly used from any program. You need to configure your terminal GUI, to use that fonts too.

### Keychain
As I often use SSH or GPG from shell and want to have some comfort too, I use [``keychain``](https://github.com/funtoo/keychain). It ensures that your SSH keys are available through ``ssh-agent``. Hence, you must install it before configuring through
```shell-session
# apt install keychain
```
Afterwards, adapt your ``.zshrc`` to include the usage of the keychain plugin and load your SSH private key stored in the file ``id_rsa`` in your main SSH directory, i.e. usually ``~/.ssh/``.

```zsh
plugins=(... keychain ...)
zstyle :omz:plugins:keychain agents gpg,ssh
zstyle :omz:pluginz:keychain identities id_rsa
```