Working in data science requires a lot of time with commands in the terminal. Whether it’s running scripts, versioning, running and managing containers – the various jobs on the terminal find us everywhere.

The default is now on most Linux and MacOS machines zsh terminal. And it normally looks like this:

Old suffix. Not a very spectator, is it?

There is nothing stopping us from admitting that it looks quite boring. Now add its widespread use to our daily lives and get an idea of ​​how monotonous it can feel.

This is where the magic of customization fits.

zsh the terminal makes it easy for us, data scientists who know a little mysterious dotfiles, develop your own terminal with an easily customized (themed) look and many highly powerful features.

I want to show you how I used the open source library and some of my own customizations to upgrade my terminal to this, within an hour:

new terminal! looks like dope, right?

Here we go

ohmyzsh is a library that prides itself on being the ultimate framework for customizing the zsh terminal.

It has a huge collection of great themes, essential extensions in every developer theme you can imagine, and has the flexibility to customize them too!

All in all, it’s almost the bread and butter of our terminal viewer, so let’s go ahead and install it on our system.

But first, check .zshrc file in the home directory. If it is blank, go to the installation below, if not, make sure you back up the file first. ohmyzsh will substantially overload the file when you install it, so all your previous configurations will be lost otherwise.

I had to make a backup because I wanted to make sure the miniconda configuration and Android SDK paths were not lost.

Okay, the installation can be done with a simple command:

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

There are other ways to install the library on the GitHub page. Be sure to check it out if you can’t do it this way.

Now let’s move on to the stage where we apply the theme to our terminal!

Its wiki the library page lists more than a hundred themes with corresponding screenshots. Go ahead and set aside time to browse and select the one you want.

I chose for this demonstration dstufft theme.

Open .zshrc file in your favorite text editor and paste these lines into them:

export ZSH="/Users/username/.oh-my-zsh"ZSH_THEME="dstufft"
# at the end of the file
source $ZSH/oh-my-zsh.sh

Remember replaces your username and save it. Go now and open a new terminal.

The theme terminal is now ready for use!

Glorious! You’ve done it! I said it was simple, right? 😄

Now comes the fun part. If you don’t like the colors defined in the theme and want to customize it with your own (like me), you can do that too.

Let’s see how!

Open the terminal and enter:

spectrum_ls

You will see a printout consisting of the following lines of color and number:

you have several colors available!

Now open the theme source code from the directory → ~ / .oh-my-zsh / themes /dstufft.zsh theme

Let’s look at the different parts we can change:

function prompt_char {  git branch >/dev/null 2>/dev/null && echo '±' && return    hg root >/dev/null 2>/dev/null && echo 'Hg' && return    echo '*'} 

Notice the bold signs here. They are prompt symbols which is displayed on the terminal. Change them the way you want with any other symbol or even emo!

Next we have the bulk of the prompt – hostname and username with directory description.

PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info)$(virtualenv_info)$(prompt_char) '

You can change the parts highlighted in bold. These are places you can replace previously selected color codes.

Just replace $ fg[magenta] with $ FG[COLOUR-CODE] everywhere you want a different color.

The same applies to the rest of the theme code. There you can change the way git branch information appears:

ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"ZSH_THEME_GIT_PROMPT_CLEAN=""

When you are done, save the file and open a new terminal.

You should now see the changes appear at the prompt.

The last thing I did was kind of alias commands.

These reflect the commands I often use on the terminal and the ones I would like to make an abbreviated version of. That’s all there is to it.

For example, now i can write and write:

gs

instead of perfect:

git status

to get my git branch status. And so, you get the idea.

Aliases can be defined as follows .zshrc file also:

alias gs="git status";alias gb="git branch";# and so on...keep all you want to!

And that’s pretty much how I customized the look and feel of the terminal by adding some productivity features.

Where to go from here? Well, I can recommend that you explore more extensions available from the ohmyzh repository. They talk quite a bit about their usefulness, and some of them also offer a lot of ready-made aliases!

LEAVE A REPLY

Please enter your comment!
Please enter your name here