Terminal customization and expansion: Oh My Zsh and VSCode

Terminal customization and expansion: Oh My Zsh and VSCode

Subscribe to my newsletter and never miss my upcoming articles

Oh My Zsh is a delightful open source framework for managing Zsh configuration. It comes bundled with thousands of useful features, plugins and themes. For Oh My Zsh to work, you need to have Zsh installed.

Installing on Linux

The installation process for Zsh on different platforms is described here. On Ubuntu, installation is performed with the following commands:

  1. sudo apt install zsh
  2. chsh -s $(which zsh)

Log out and log back in to use the new shell. Open terminal and enter 0 for Zsh configuration.

1.png

Now, to install Oh My Zsh, enter the command:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

2.png

Select Zsh in VSCode terminal:

3.png

Adding plugins on Linux

To install a plugin, you need to add its name to the plugins array in the file ~/.zshrc, For example, to add a Git plugin, open the file ~/.zshrc, find the line plugins = ( ...) and add git there: plugins = (... git). A list of all plugins is available here.

Changing theme on Linux

To change the theme, open the file ~/.zshrc, find the line ZSH_THEME = "..." and specify the name of the desired theme, for example: ZSH_THEME =" robbyrussell". A list of all themes is available here.

Installing on Windows

Download Cygwin here (setup-x86_64.exe file) and install. At the stage of choosing a site for downloading, choose any of the options. At the stage of choosing packages for installation, in the "view" drop-down list, select "Full", in the "Search" field, type "wget" and press Enter. Then in the "new" column for the "wget" package, press the button with the triangle and, in the drop-down list, select any version. I chose version 1.21.1-1.

4.png

5.png

6.png

7.png

8.png

9.png

10.png

Run Cygwin as administrator and run the command wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg.

11.png

Run the command install apt-cyg /bin

12.png

Run the following commands:

  1. apt-cyg install zsh git
  2. git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
  3. cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

13.png

Launch VSCode and open the preferences (File / Preferences / Settings or the keyboard shortcut Ctrl + ,). If you have opened the graphical settings interface, then click the "Open Settings (JSON)" button in the upper right corner. Add the following settings:

"terminal.integrated.shell.windows": "C:\\cygwin64\\bin\\zsh.exe",
"terminal.integrated.env.windows": {
    "CHERE_INVOKING": "1"
},
"terminal.integrated.shellArgs.windows": ["--login"]

Open a new terminal VSCode (Terminal / New Terminal or with the keyboard shortcut Ctrl + Shift + \` ). If you did everything correctly, the terminal should be using a Zsh shell with the Oh My Zsh framework.

14.png

To install a plugin, add its name to the plugins array in the fileC:\cygwin64\home\[Username]\.Zshrc. For example, to add a Git plugin, open the file C:\cygwin64\home\[Username]\.Zshrc, find the line plugins = (...) and add git there: plugins = (... git). A list of all plugins is available here. Don't forget to replace [Username] with your username.

Changing theme on Windows

To change the theme open the file C:\cygwin64\home\[Username]\.Zshrc, find the line ZSH_THEME = "..." and specify the name of the desired theme, for example: ZSH_THEME = "robbyrussell". A list of all themes is available here. Don't forget to replace [Username] with your username.

 
Share this