Adding functionality
Command shell
Most distributions come with Bash built in. Using addons you can make whatever you want out of it, but it's much easier to do it with Zsh . Why?
- Advanced mechanics of autocomplete commands by pressing <Tab> or <Arrow Up>. Unlike Bash, you do not need to configure this, everything works at the highest level right out of the box.
- Lots of ready-made themes, modules, plugins and more. Customizability through frameworks (oh-my-zsh, prezto, etc.), which greatly expand the possibilities of customizing and improving the terminal. Again, all of this can be achieved in Bash, but there is a ton of readymade material for Zsh. For Bash, there are significantly fewer of them, and some do not.
These are the main reasons I switched from Bash to Zsh. Apart from this, Zsh has many other goodies.
Setting up Zsh
First, install Zsh (if it is already installed, for example, as in Manjaro, you can skip this step):
sudo apt install zsh
When prompted to set Zsh as the default shell, click
Y
to confirm.
Oh-My-Zsh is a popular and actively developing Zsh framework that allows flexible customization of the terminal shell. Let's install it:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
zsh: command not found: curl
curl
:
sudo apt install curl
Syntax highlighting. It is much easier to navigate through the contents of the terminal when different parts of the commands are highlighted in different colors. For example, directories will be underlined, and commands will be highlighted in a color other than normal text. Install the plugin
zsh-syntax-highlighting
:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
zsh: command not found: git
git:
sudo apt install git
For the plugin to work, you need to connect it.
In the file,
~/.zshrc
change the line from plugins=
:
plugins=(git zsh-syntax-highlighting)
If there is no such line, add it.
Done! We get a convenient and functional terminal. Now let's make it visually pleasing.
Customizing the look
Install the PowerLevel10K theme :
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
Download and add a font
JetBrains Mono Nerd
(with icons) to the system:
Select one from the list , in the folder
/complete
select a font without "Windows Compatible", with the ending "Mono".
We connect the font and theme.
Editing
~/.zshrc
.
If these lines already exist in the file, replace them.
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_MODE="nerdfont-complete"
Colors. An important part of the terminal design is the color scheme. I went through a lot of different schemes, edited them, settled on Monokai Dark. Does not hurt the eyes, but at the same time pleasant and bright. Color list:
[colors]
# special
foreground = #e6e6e6
foreground_bold = #e6e6e6
cursor = #fff
background = #000
# black
color0 = #75715e
color8 = #272822
# red
color1 = #f92672
color9 = #f92672
# green
color2 = #a6e22e
color10 = #a6e22e
# yellow
color3 = #434648
color11 = #7ea35f
# blue
color4 = #66d9ef
color12 = #66d9ef
# magenta
color5 = #ae81ff
color13 = #ae81ff
# cyan
color6 = #adb3b9
color14 = #62ab9d
# white
color7 = #2AA198
color15 = #2AA198
The color scheme changes differently in different terminals (usually this is done through the terminal settings), but the order of colors is the same everywhere. You can import this template into Termite format and export it to your terminal through terminal.sexy
Run configuration topics:
p10k configure
.
Customize your theme by choosing the display options you like best.
The final touch is to change the theme config and replace the built-in colors.
Editing the file
~/.p10k.zsh
.
If these lines already exist in the file, replace them. Color codes can be obtained by command
for i in {0..255}; do print -Pn \"%K{$i} %k%F{$i}${(l:3::0:)i}%f \" ${${(M)$((i%6)):#3}:+$'\n'}; done
- Displaying only the current directory:
typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_last
- Directory block background:
typeset -g POWERLEVEL9K_DIR_BACKGROUND=33
- Arrow colors:
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=2
and
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=1
- Git branch background:
typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=15
Result
Error:
GIT:
Sources
PowerLevel10K Documentation
Online Terminal Color Scheme Designer
Differences Between Bash and Zsh