We can configure aliases very easily in bash or zsh. but those aliases are global to all directory. sometimes we need aliases or commands only for some directories alone. this plugin makes the process easy. those aliases will be available only to that particular directory. aliases will be loaded when you
cd into the directory and unloaded once you leave the directory.
clone plugin from github
git clone https://github.com/Gokuldroid/zen-alias ~/.oh-my-zsh/plugins/zen-alias
check if the plugin is cloned correctly
add zen-alias like this
# Which plugins would you like to load? # Standard plugins can be found in $ZSH/plugins/ # Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. plugins=( git zen-alias )
updating the plugin
cd <cloned directory> && git pull
copy the file to root directory or somewhere in your system.
curl -S https://raw.githubusercontent.com/Gokuldroid/zen-alias/main/zen-alias.plugin.zsh > ~/.zen-alias.bash
source the file in bashrc
add this line at the end of the bashrc
Create .aliases file in the root directory of the project. add your per project aliases like this. You can find a sample file here.
yc: yarn w @zen-alias/client ys: yarn w @zen-alias/server ycommon: yarn w @zen-alias/common ybg: yarn w @zen-alias/bg-jobs yb: yarn build yw: yarn watch
incase if you don't want others to use your aliases, you can add it global .gitignore or project .gitignore
cd ~ touch .gitignore_global git config --global core.excludesfile ~/.gitignore_global echo ".aliases" > ~/.gitignore_global
we might want to execute some script as soon as we enter the project. like updating local branch or setting up nvm or rvm version etc. zen-alias provides an easy way for this.
define a zen-alias like this,
init_zen_dir: nvm use && rvm use