← Today I Learned

Launch GitKraken from your terminal

Use an alias to open your repository in GitKraken.

  • development
  • git
  • gitkraken
  • alias
  • terminal
  • workflow
  • zsh
  • bash
Published

Sep 13, 2020 @ 8:45 PM

Overview

Summary

I prefer to use GitKraken for managing my repositories. However, it's gotten to the point where it's way too much work to open the GitKraken app, and then select my recent repository. I found a faster way to do it thought the terminal with the following command:

open -a "GitKraken" --args -p $(pwd)

Source

Since we both already forgot that, let's create an alias so that we can open our repository in GitKraken with a single command: kraken. An alias is basically a custom command that runs another command. It's used when you are to lazy smart to type out a longer command that you use frequently.

Usage

Terminal

Create a custom alias named kraken by typing the following in your terminal:

$ alias kraken='open -a "GitKraken" --args -p $(pwd)'

Source

To list your aliases, just type the alias command:

$ alias

The output is the following:

kraken='open -a "GitKraken" --args -p $(pwd)'

Source

You can delete your alias with the unalias command:

$ unalias kraken

Source

Persisting aliases (configuration file)

You may notice the above method doesn't persist your alias after you close the terminal. To persist your alias, you need to add it to your terminal's configuration file. I'm using zsh, so I will add the following line to my ~/.zshrc file:

alias kraken='open -a "GitKraken" --args -p $(pwd)'

For bash terminals, you can add this command to your ~/.bash_profile (for Mac) or ~/.bashrc files. If you are not sure what terminal you are using you can check with the following command:

$ echo "$SHELL"

The output is the following:

/bin/zsh

Example

Once you have created the alias, navigate to your repository and run the kraken command.

$ cd Development/my-project
$ kraken

This should launch your repository in a new tab in GitKraken! 😎

Resources

All rights reserved 2022