Iterm 2 Git

broken image


  1. Click the git status component to get the following options: Commit - Runs git commit. A window will open for you to enter the commit message if needed. Add & Commit - Runs git commit -a. A window will open for you to enter the commit message if needed. Stash - Runs git stash; Log - Runs git log and shows the result in a popover.
  2. My Terminal Setup: iTerm2 + Zsh 🔥. Passionate about education, Python, JavaScript, and code art. As a follow up to my post on my text editor setup, I wanted to write about the other key part of my development setup - my terminal. Unlike my relatively new text editor setup, my terminal configuration has followed me around for years.
  3. For me this was not a git issue, but it was an iTerm2 issue on macOS. I ended up solving this by going to the iTerm2 Preferences Window Check the 'Keep background colors opaque' checkbox and should now have no more pain or sorrows!

If your computer doesn't recognize git as a command, you must install Git.After you install Git, run git -version to confirm that it installed correctly. To start using Git from your computer, you must enter your credentials to identify yourself as the author of your work. Gm- git merge; dk- docker kill; and so on. Now the challenge is I use iTerm 2 for connecting to various remote sessions and I wish these aliases work seamlessly on all sessions. Is there a way to push these aliases into a global context so that iTerm 2 will input the original command upon detecting these aliases.

by Chiamaka Ikeanyi

Sometimes, using the default terminal sucks. You want to go out of the ordinary, to add life to the boring terminal and improve your productivity.

Z shell (Zsh) is a Unix shell built on top of bash (the default shell for macOS) with a large number of improvements.

In this walk-through, we will configure iTerm2 with ZSH and its dependencies. This is a no-brainer, and after this, you'll ponder the reason for not discovering ZSH earlier. Well, since you're here already, let's kick-start this.

Keynotes

  • Homebrew installation
  • iTerm2 installation
  • ZSH and Oh My ZSH installations
  • Setting up the dependencies to create a beautiful terminal

Step 1: Install Homebrew

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's macOS.

Before installing Homebrew, we need to install the CLI tools for Xcode. Open your terminal and run the command:

If you get an error, run xcode-select -r to reset xcode-select.

Iterm2 git branch

Then, install Homebrew.

Step 2: Install iTerm2

iTerm2 is a replacement for terminal and the successor to iTerm. Most software engineers prefer iTerm2 over the default terminal that ships with macOS as a result of its cool features. You can integrate zsh into iTerm2 to increase productivity.

To install iTerm2, run the command:

Step 3: Install ZSH

Zsh is a shell designed for interactive use, although it is also a powerful scripting language.

By default, macOs ships with zsh located in/bin/zsh.

Let's install zsh using brew and make iTerm2 use it.

Step 4: Install Oh My Zsh

'Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. It will not make you a 10x developer…but you might feel like one'
— Robby Russell

It runs on Zsh to provide cool features configurable within the ~/.zhrc config file. Install Oh My Zsh by running the command

Check the installed version

You can upgrade it to get the latest features it offers.

Restart iTerm2 to dive into the new experience of using Zsh. Welcome to the 'Oh My Zsh' world ?.

That's not all. Now, we will install the dependencies to get the best out of Zsh.

Step 5: Change the Default Theme

Oh My Zsh comes bundled with a lot of themes. The default theme is robbyrussell, but you can change it to any theme of your choice. In this scenario, I changed it to agnoster, an already pre-installed theme.

You then need to select this theme in your ~/.zshrc. To open the config file (.zshrc), run the command:

Or open the file in a text editor with

Set the zsh theme and update your changes Workspaces 0 9 3 – organize your work (beta).

Using a Custom Theme

To install another theme not pre-installed, clone the repository into custom/themesdirectory. In this scenario, we'll install powerlevel9k,

Then, select this theme in your ~/.zshrc

Iterm2 Git Command

Update your changes by running the command source ~/.zshrc

Navigate to iTerm2 > Preferences > Profiles > Colors if you wish to change the background color of the terminal.

The selected theme in this scenario requires powerline fonts. So, let's install that.

Step 6: Install Fonts

I will be using Inconsolata. Get your preferred font out of these powerline fonts. Then, download and install it.

Or download the entire font.

To change the font, navigate to iTerm2 > Preferences > Profiles > Text > Change Font.

Now, you can see Inconsolata listed as one of the fonts. Select your preferred font. For fonts that support ligatures like FiraCode, check the 'Use ligatures' option to view your arrows and other operators in a stylish manner like ( ).

Step 7: Install Color Scheme

Let's change the color scheme to bring out the beauty of our terminal. Navigate to iTerm2-Color-Schemes and download the ZIP folder. Then, extract the downloaded folder cos what we need resides in the schemes folder.

Navigate to iTerm2 > Preferences > Profile > Colors > Color Presets > Import

  • Navigate to the schemes folder and select your preferred color schemes to import them.
  • Click on a specific color scheme to activate it. In this scenario, I activated Batman which is my preferred color scheme.

Tada! ? We're done with the basic settings.

Step 8: Install Plugins

Oh My ZSH comes preloaded with a git plugin. To add more, for instance, docker, auto-suggestion, syntax highlighting and more:

  • Clone the Git repository
  • Head over to .oh-my-zsh > custom > plugins directory to view the cloned directory. To access this, run the command open ~/.oh-my-zsh
  • Add the plugin to the plugin section of the config file ~/.zshrc shown below
  • Update your changes by running the command source ~/.zshrc

Step 9: Add Aliases

Aliases are shortcuts used to reduce the time spent on typing commands. Add aliases to commands you run in the section shown below.

Thanks for reading.

If you know about other means of improving productivity using ZSH, you can drop them on the comment section, I will be glad to hear from you.

So iTerm2 has this neat imgcat command that allows you to 'cat' orview an image right in the terminal. It's pretty sweet, but I had anidea: what if we used that with Git for diffing changed images in agit diff?

This seems like it should be possible, you can replace what git doeswhen you do a diff of two different binary files. For example, thespaceman-diff package by Zach Holmandoes this to do a diff of two images as ascii art.

We want to do the same, but instead of seeing an ASCII art versionof an image, it'd be cool to see the two versions of the image itselfright in the terminal.

Setting Git Attributes

The first thing is create a file in your home directory called~/.config/git/attributes. In here you can define a mapping between file typesand what command Git will run when doing a diff of those filetypes. In my caseI entered the following:

This tells git that when doing a diff of a file that ends with png, jpg,gif, or jpeg to use the image config.

Set Up The Image Config

Now, in your ~/.gitconfig file, add the following:

Disk cleaner free your hard drive space 1 2. This tells Git to use iTerm's imgcat script for converting the binary imagefile to text. This seems weird, but this is actually how iTerms imcat commandworks: it converts the binary image into a textual stream that iTerm knows howto understand and then render as an actual image.

Put imgcat In Your Path

Next is put iTerm's imcat script somewhere on your path. You can download itfrom here. Save that somewhere, make sureyou chmod it to be executable (chmod +x imgcat), and then throw it into somedirectory on your path. You can confirm it's there by typing imgcat into aniTerm window:

Note that you have to put this script in your path, you can't just rely on theversion that's inlined into your terminal with iTerm's shell integration.

Iterm2 Git Download

Profit

Iterm2 Git Extension

Now when you change an image in a Git repo and do a git diff while in iTermyou'll see a preview of the original image and the changed image. Example:

The above image is the original, the 2nd image is what I changed it to. Notethat because imgcat is iTerm specific, it won't work in other terminals. Ifyou do a git diff in a different terminal (ex: the integrated terminal inVS Code) you'll see just the ordinary blank output:

Iterm2 Git Login

Please enable JavaScript to view comments.



broken image