mirror of
https://github.com/GRFreire/dotfiles.git
synced 2026-01-10 04:19:38 +00:00
zsh: source fast-nvm script
this makes so if you cd into a directory with a .nvmrc, it will exec nvm use
This commit is contained in:
parent
d60c4fe16b
commit
a7eb216330
27
.fast-nvm.sh
Normal file
27
.fast-nvm.sh
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
locate_nvmrc() {
|
||||||
|
locate -w .nvmrc | xargs -I'{}' realpath --relative-to=. '{}' | awk '/^(\.\.\/)*\.nvmrc$/ {print $0}' | sort | xargs -I'{}' realpath '{}'
|
||||||
|
}
|
||||||
|
|
||||||
|
export PATH="$HOME/.nvm/versions/node/$(/bin/cat $HOME/.nvm/alias/default)/bin:$PATH"
|
||||||
|
nvm() {
|
||||||
|
. $HOME/.nvm/nvm.sh; nvm "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFAULT=$(locate_nvmrc)
|
||||||
|
cd() {
|
||||||
|
if builtin cd "$@" 2>/dev/null; then
|
||||||
|
FOUND="$(locate_nvmrc)"
|
||||||
|
if [ "$DEFAULT" != "$FOUND" ]; then
|
||||||
|
DEFAULT=$FOUND
|
||||||
|
nvm use
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if test -f "$@"; then echo "cd: not a directory: $*"
|
||||||
|
elif test -d "$@"; then echo "cd: can not change to $*"
|
||||||
|
else echo "cd: no such file or directory: $*"
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
5
.zshrc
5
.zshrc
@ -60,10 +60,7 @@ alias zathura="devour zathura"
|
|||||||
alias ranger="source ranger"
|
alias ranger="source ranger"
|
||||||
|
|
||||||
# This loads nvm
|
# This loads nvm
|
||||||
export PATH="$HOME/.nvm/versions/node/$(/bin/cat $HOME/.nvm/alias/default)/bin:$PATH"
|
source $HOME/.fast-nvm.sh
|
||||||
nvm() {
|
|
||||||
source $HOME/.nvm/nvm.sh; nvm "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if is integrated terminal emulator
|
# Check if is integrated terminal emulator
|
||||||
if [ -z "$INTEG_EMU" ]; then
|
if [ -z "$INTEG_EMU" ]; then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user