Oh My Zsh Git Plugin
Learn to boost your terminal efficiency
Shortcuts will increase productivity. If you are version controlling with git, I assume you use commands like “git branch” quite often to check which branch you’re at and check the branch name you want to go to next then “git checkout <branch name>” to get there.
Typing words like “git branch” and “git checkout <branch name>” may not seem that much of an effort, but what if you can reduce “git branch” down to only “gb” and do the same with other commands too?
Introducing Git Plugin in Oh My Zsh
Before installing git plugin, you need to have zsh and Oh My Zsh installed on your computer.
1. Make sure that you already have zsh installed and your default shell is zsh.
Type the command below to see your default shell.
echo $SHELL // /bin/zsh
If you don’t see /bin/zsh as an output, you need to switch the default shell to zsh by running the command below.
chsh -s /bin/zsh
And close the terminal, open up a new one and your default shell should be set as zsh now.
2. Check the version of your zsh
Run either one of the commands below to check the version.
The Oh My Zsh official README says “v4.3.9 or more recent is fine but we prefer 5.0.8 and newer)” so make sure that you version is compatible.
3. Install Oh My Zsh
Run either one of the commands below to install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
You should be able to see something like below after successful installation
4. Add a git plugin 🔨
Open .zshrc file in a vim editor with the command blow
(Update on July/24/2020)
Oh-my-zsh comes with git plugin by default now so please skip the instruction below after you confirm that you already have git plugin installed
And scroll down until you find “plugins=()”. (This is where you load plugins you would like to use.)
Put “git” inside (), save the file(:wq) and close the terminal.
If you would like to use multiple plugins, the syntax is below (Just put a space between plugin names!)
plugins=(rails git ruby docker yarn)
5. Time to see the magic 🎉
Go to your random git repository before using git aliases.
gb -> git branch
gcm -> git checkout master
gst -> git status
ga . -> git add .
gcmsg -> git commit -m
ggf -> git push -f
gl -> git pull
gco [branch name] -> git checkout [branch name]
glo -> git log --oneline --decorate
Hope you will start to have more productive days as an engineer with the power that the plugin brings!
Check their github repo out from below