Skip to content

Commit 67e927b

Browse files
authored
Merge pull request #30 from selfisekai/nvm-installer
nvm installer script
2 parents 6a38139 + 8eb03cc commit 67e927b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

installers/nvm/installer.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# nvm is not available as a distro package, installing manually from git to ~/.nvm
4+
5+
# install git - required dependency
6+
if [ ! -f $(which git) ]; then
7+
curl https://installer.to/git | bash
8+
fi
9+
10+
# https://github.com/nvm-sh/nvm#git-install
11+
cd ~
12+
git clone https://github.com/nvm-sh/nvm.git .nvm
13+
cd ~/.nvm
14+
# checkout latest github release
15+
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
16+
17+
cd ~
18+
for FILE in .bashrc .zshrc .profile
19+
do
20+
# if file exists and doesn't already have "NVM_DIR" inside
21+
if [[ -f $FILE && -z $(cat $FILE | grep NVM_DIR) ]]; then
22+
# to make nvm accessible on new terminal windows and after a reboot
23+
echo '
24+
export NVM_DIR="$HOME/.nvm"
25+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
26+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> $FILE
27+
fi
28+
done
29+
30+
# to make nvm accessible right after installing
31+
export NVM_DIR="$HOME/.nvm"
32+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
33+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

0 commit comments

Comments
 (0)