{"id":6,"date":"2022-09-26T18:31:03","date_gmt":"2022-09-26T18:31:03","guid":{"rendered":"https:\/\/blog.douwedevri.es\/?p=6"},"modified":"2025-10-24T11:51:24","modified_gmt":"2025-10-24T09:51:24","slug":"oh-my-zsh-with-autosuggestions-and-syntax-highlighting","status":"publish","type":"post","link":"https:\/\/blog.dbdv.nl\/?p=6","title":{"rendered":"Oh My ZSH! with autosuggestions and syntax-highlighting"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial works for <strong>Linux <\/strong>and <strong>macOS <\/strong>systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the next instructions to work the following packages must be installed:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>zsh<\/code><\/li>\n\n\n\n<li><code>curl<\/code><\/li>\n\n\n\n<li><code>git<\/code><\/li>\n\n\n\n<li><code>vim <\/code>(or any other text-editor)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Oh My ZSH!<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"337\" height=\"208\" src=\"https:\/\/blog.douwedevri.es\/wp-content\/uploads\/2022\/09\/OMZLogo_BnW.png\" alt=\"\" class=\"wp-image-40\" srcset=\"https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/OMZLogo_BnW.png 337w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/OMZLogo_BnW-300x185.png 300w\" sizes=\"auto, (max-width: 337px) 100vw, 337px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">First, let&#8217;s install Oh-My-ZSH.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sh -c \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/robbyrussell\/oh-my-zsh\/master\/tools\/install.sh)\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively you could use the method provided at <a href=\"https:\/\/ohmyz.sh\/#install\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/ohmyz.sh\/#install<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Plugins<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"702\" src=\"https:\/\/blog.douwedevri.es\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-26-at-20.58.18-1024x702.png\" alt=\"\" class=\"wp-image-38\" srcset=\"https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-26-at-20.58.18-1024x702.png 1024w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-26-at-20.58.18-300x206.png 300w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-26-at-20.58.18-768x526.png 768w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-26-at-20.58.18-1536x1053.png 1536w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-26-at-20.58.18-1568x1075.png 1568w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-26-at-20.58.18.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Oh-My-ZSH on macOS in iTerm2. The input is showing autosuggestion and syntax-highlighting in action.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Oh-My-ZSH allows us to install plugins. Two useful plugins are <strong>autosuggestions <\/strong>and <strong>syntax-highlighting<\/strong>. Both are available at <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/zsh-users\" target=\"_blank\">https:\/\/github.com\/zsh-users<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s clone the <a href=\"\/\/github.com\/zsh-users\/zsh-autosuggestions\" target=\"_blank\" rel=\"noreferrer noopener\">autosuggestions repository<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/zsh-users\/zsh-autosuggestions.git $ZSH_CUSTOM\/plugins\/zsh-autosuggestions<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, do the same for <a href=\"https:\/\/github.com\/zsh-users\/zsh-syntax-highlighting\" target=\"_blank\" rel=\"noreferrer noopener\">syntax-highlighting<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/zsh-users\/zsh-syntax-highlighting.git $ZSH_CUSTOM\/plugins\/zsh-syntax-highlighting<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Furthermore, we can install a custom theme <a href=\"https:\/\/github.com\/romkatv\/powerlevel10k\" data-type=\"link\" data-id=\"https:\/\/github.com\/romkatv\/powerlevel10k\" target=\"_blank\" rel=\"noreferrer noopener\">powerlevel10k<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/romkatv\/powerlevel10k.git $ZSH_CUSTOM\/themes\/powerlevel10k<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that the two plugins and theme are downloaded, we need to add them to the file <code>.zshrc<\/code>. Using your favorite text-editor open <code>~\/.zshrc<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim ~\/.zshrc<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Within the file search for <code>plugins=(git)<\/code>, and append the two new plugins as follows. Please note that the plugins are separated using spaces.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plugins=(git zsh-autosuggestions zsh-syntax-highlighting)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the above is added, save the file. For vim: hit <kbd>ESC<\/kbd><strong> <\/strong>and  then two times <kbd>shift + Z<\/kbd>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We also need to specify the installed theme to make it go into effect.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ZSH_THEME=\"powerlevel10k\/powerlevel10k\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To make the changes in <code>~\/.zshrc<\/code> go into effect, reopen the terminal. Alternatively to reopening the terminal, source the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source ~\/.zshrc<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Updating<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Once in a while, updates will be pushed to the repositories. Pull the changes to keep the local repositories up-to-date.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd $ZSH_CUSTOM\/plugins\/zsh-autosuggestions; git pull<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>cd $ZSH_CUSTOM\/plugins\/zsh-syntax-highlighting; git pull<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This can also be done for the theme.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd $ZSH_CUSTOM\/themes\/powerlevel10k; git pull<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-family: var(--wp--preset--font-family--body); font-size: var(--wp--preset--font-size--medium);\">And if you would like to go reconfigure your powerlevel10k theme, do so with the following command.<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p10k configure<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Troubleshooting<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">During my experience with autosuggestion, I encountered a problem on macOS. When entering a value that can be completed using autocompletion, it would not properly complete. This issue was submitted here <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/zsh-users\/zsh-autosuggestions\/issues\/686\" target=\"_blank\">https:\/\/github.com\/zsh-users\/zsh-autosuggestions\/issues\/686<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"autosuggestions bug\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/vyQoVTQ9iT8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">Input showing bug in autosuggestion on macOS.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To solve this bug, make sure to put the following lines in your <code>~\/.zshrc<\/code> file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export LC_ALL=en_US.UTF-8<br>export LANG=en_US.UTF-8<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Don&#8217;t forget to source the file after saving it, like instructed above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites This tutorial works for Linux and macOS systems. For the next instructions to work the following packages must be installed: Oh My ZSH! First, let&#8217;s install Oh-My-ZSH. Alternatively you could use the method provided at https:\/\/ohmyz.sh\/#install. Plugins Oh-My-ZSH allows us to install plugins. Two useful plugins are autosuggestions and syntax-highlighting. Both are available at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":40,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[5,4,6],"class_list":["post-6","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-linux","tag-macos","tag-zsh"],"_links":{"self":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6"}],"version-history":[{"count":30,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":326,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions\/326"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/media\/40"}],"wp:attachment":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}