Skip to content

Instantly share code, notes, and snippets.

View akhtarja's full-sized avatar
🏠
Working from home

Javed Akhtar akhtarja

🏠
Working from home
View GitHub Profile
@akhtarja
akhtarja / nvm_automation.sh
Last active June 1, 2020 03:14
Add to `.zshrc` to automatically change your Node version depending on your folder's `.nvmrc` file (requires ZSH and NVM)
# NVM automation
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then