The idea behind this script is that we have many git repos (dozens of them) working in an environment that embrace microservices.
As a result, we have many folders under the workspace.
It becomes time consuming simply switching from one git repo to another.
This script is for generating a shortcut for opening repo from the command line.
For example, if you have a repo called Mumbai
, you can simply switch to that repo by typing go2_mumbai
in your terminal regardless where you are.
We use conda
for managing environment here. Cheat sheet for create, update, and sharing.
conda env create -f environment.yml
conda env update -f environment.yml
conda env export --no-builds | grep -v "prefix" > environment_freeze.yml
Activate environment and run alias_gen
.
conda activate alias_gen
python alias_gen.py
It which will then generate a file ~/.alias-gen
.
#
# Generated by alia-gen.py
#
alias detroit="cd /Users/yuchen/Documents/Detroit"
alias draggablepanel="cd /Users/yuchen/Documents/DraggablePanel"
alias durham="cd /Users/yuchen/Documents/Durham"
alias helpers="cd /Users/yuchen/Documents/Helpers"
alias mountainview="cd /Users/yuchen/Documents/MountainView"
alias mumbai="cd /Users/yuchen/Documents/Mumbai"
# Skiping directory 'RxSwift_Reactive_Programming_with_Swift_v2.0' because it is not a git repo
alias seattle="cd /Users/yuchen/Documents/Seattle"
alias springfield="cd /Users/yuchen/Documents/Springfield"
You can add --dry-run
to see the output before saving the output to file.
And finally add this to ~/.bash_profile
so that it updates automatically.
# Added for generating alias for navigating to git repos
if [ -f ~/.alias_gen ]; then
. ~/.alias_gen;
fi