{"id":2030,"date":"2022-05-20T05:49:44","date_gmt":"2022-05-20T00:19:44","guid":{"rendered":"https:\/\/smarttech101.com\/?p=2030"},"modified":"2022-11-12T02:04:51","modified_gmt":"2022-11-11T20:34:51","slug":"zsh-highlighting-autosuggestion-themes-binding-alias-fzf","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/zsh-highlighting-autosuggestion-themes-binding-alias-fzf\/","title":{"rendered":"zsh: highlighting, autosuggestion, themes, binding, alias, fzf"},"content":{"rendered":"\n
Zsh (or Note: I recommend you to follow this article from top to bottom to minimize the problems.<\/strong><\/p>\n\n\n\n Debian, Ubuntu, and Kali Linux<\/p>\n\n\n\n Alpine<\/p>\n\n\n\n Arch Linux<\/p>\n\n\n\n CentOS<\/p>\n\n\n\n Fedora<\/p>\n\n\n\n macOS:<\/p>\n\n\n\n Or with Homebrew<\/p>\n\n\n\n Raspbian<\/p>\n\n\n\n To make it the default shell, execute the following command:<\/p>\n\n\n\n When you start Press Put the following three lines in the Here,<\/p>\n\n\n\n Now, now you can set the following option(s) using the Where,<\/p>\n\n\n\n Turn off the beef sound on errors. By default, it is on:<\/p>\n\n\n\n Now, to enable the tab completion, put the following commands in your fzf-tab<\/a> replaces z shell’s default completion selection menu with fzf.<\/p>\n\n\n\n Take a look at this video<\/a> to understand its importance. You don’t have to remember anything now<\/strong>.<\/p>\n\n\n\n To enable it just download it using git:<\/p>\n\n\n\n And now source the main file into Note:<\/strong> Please note that you should put the above command after the For this, we will use According to the zsh-completions website<\/a>, it “aims at gathering\/developing new completion scripts that are not available in Zsh yet”.<\/p>\n\n\n\n Installation using official repositories<\/strong>: It is available in most of the official repositories of your distributions. Install from there and you are done. Nothing to do anymore.<\/p>\n\n\n\nz-shell<\/code>), like
bash<\/code>, is a POSIX compliant shell. Therefore, most of the bash commands are applicable in z-shell as well. However, bash does not provide features like autosuggestion, and syntax highlighting among other modern features. On the other hand,
fish<\/code> shell provides these features out of the box but
fish<\/code> is not POSIX compliant. So, our best solution is this shell.<\/p>\n\n\n\n
Table of Contents<\/h2>\n\n\n\n
Installation and make zsh default shell<\/h2>\n\n\n\n
apt-get install zsh<\/code><\/pre>\n\n\n\n
apk add zsh<\/code><\/pre>\n\n\n\n
pacman -S zsh<\/code><\/pre>\n\n\n\n
yum install zsh<\/code><\/pre>\n\n\n\n
dnf install zsh<\/code><\/pre>\n\n\n\n
$ sudo port install zsh<\/code><\/pre>\n\n\n\n
brew install zsh<\/code><\/pre>\n\n\n\n
apt-get install zsh<\/code><\/pre>\n\n\n\n
~$ sudo chsh -s $(which zsh)<\/code><\/pre>\n\n\n\n
Basic Configuration<\/h2>\n\n\n\n
Z shell<\/code> for the first time, you will get the following prompt:<\/p>\n\n\n\n
0<\/code> to create an empty file
~\/.zshrc<\/code> as suggested. This will be your configuration file. We will be populating it with our values.<\/p>\n\n\n\n
Zsh History<\/h3>\n\n\n\n
.zshrc<\/code> file:<\/p>\n\n\n\n
HISTFILE=\"${XDG_DATA_HOME:-$HOME\/.local\/share}\/zsh\/history\"\nHISTSIZE=1000000\nSAVEHIST=1000000<\/code><\/pre>\n\n\n\n
Set options for glob, correction, beep, autocd<\/h3>\n\n\n\n
setopt<\/code> command in
~\/.zshrc<\/code>:<\/p>\n\n\n\n
setopt appendhistory autocd extendedglob notify correctall nomatch globdots<\/code><\/pre>\n\n\n\n
appendhistory<\/code> make sure that Arrow keys bring your history.<\/li>
autocd<\/code> means to change into a directory say
~\/Music<\/code>, you just need to type the name of the directory only and hit Enter instead of whole
cd ~\/Music<\/code>.<\/li>
correctall<\/code> asks you to correct the mistyped words (n for no, y for yes, a for all, e for exit):<\/li><\/ul>\n\n\n\n
~$ cta ~\/.profil\nzsh: correct 'cta' to 'cat' [nyae]? y\nzsh: correct '~\/.profil' to '~\/.profile' [nyae]?<\/code><\/pre>\n\n\n\n
globdots<\/code>: include hidden files in tab completion.<\/li><\/ul>\n\n\n\n
unsetopt beep<\/code><\/pre>\n\n\n\n
tab-completion<\/h3>\n\n\n\n
~\/.zshrc<\/code> file:<\/p>\n\n\n\n
zstyle :compinstall filename \"${ZDOTDIR:-$HOME}\/.zshrc\"\n\nautoload -Uz compinit\ncompinit<\/code><\/pre>\n\n\n\n
Add-ons and plug-ins<\/h2>\n\n\n\n
fzf-tab<\/h3>\n\n\n\n
~$ git clone https:\/\/github.com\/Aloxaf\/fzf-tab<\/code><\/pre>\n\n\n\n
~\/.zshrc<\/code> by putting the following command into it:<\/p>\n\n\n\n
[ ! -f ~\/fzf-tab\/fzf-tab.plugin.zsh ] || source ~\/fzf-tab\/fzf-tab.plugin.zsh<\/code><\/pre>\n\n\n\n
compinit<\/code>, but before plugins that will wrap widgets, such as
zsh-autosuggestions<\/code> or
fast-syntax-highlighting<\/code>!<\/p>\n\n\n\n
Additional completion definitions (zsh-completions)<\/h3>\n\n\n\n
zsh-completions<\/code>.<\/p>\n\n\n\n