- development
- git
- gitkraken
- alias
- terminal
- workflow
- zsh
- bash
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)
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)'
To list your aliases, just type the alias
command:
$ alias
The output is the following:
kraken='open -a "GitKraken" --args -p $(pwd)'
You can delete your alias with the unalias
command:
$ unalias kraken
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
- git
- GitKraken
- Open GitKraken using the current repo directory in the cli
- How to Create Bash Aliases
- Linux and Unix alias command tutorial with examples
- How do I remove an alias?
- How do I list my aliases?
- How to set an alias in a macOS or Linux shell
- Shell Expansion
- Oh My Zsh
- Why doesn't .bashrc run automatically?
- How to persist an alias?