This repository has been archived by the owner on Jul 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinstall.fish
executable file
·74 lines (64 loc) · 1.68 KB
/
install.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/fish
function has
type $argv[1] > /dev/null 2>&1
return $status
end
if not test -d "$NVM_SOURCE"
set NVM_SOURCE "https://github.com/Alex7Kom/nvm-fish.git"
end
if not test -d "$NVM_DIR"
set NVM_DIR "$HOME/.nvm-fish"
end
if not has git
echo >&2 "You need to install git - visit http://git-scm.com/downloads"
exit 1
end
if test -d "$NVM_DIR"
echo "=> NVM is already installed in $NVM_DIR, trying to update"
echo -e "\r=> \c"
cd "$NVM_DIR"; and git pull
else
# Cloning to $NVM_DIR
mkdir -p "$NVM_DIR"
git clone "$NVM_SOURCE" "$NVM_DIR"
end
echo
set -l PROFILE
if test (count $argv) -gt 0; and not test -z "$argv[1]"
set PROFILE "$argv[1]"
else
if test -f "$HOME/.config/fish/config.fish"
set PROFILE "$HOME/.config/fish/config.fish"
end
end
set SOURCE_STR "test -s $NVM_DIR/nvm.fish; and source $NVM_DIR/nvm.fish"
if test -z "$PROFILE"; or not test -f "$PROFILE"
if test -z "$PROFILE"
echo "=> Config not found. Tried ~/.config/fish/config.fish"
echo "=> Create it and run this script again"
else
echo "=> Config $PROFILE not found"
echo "=> Create it and run this script again"
end
echo "=> Run this script again after running the following:"
echo
echo " touch $HOME/.config/fish/config.fish"
echo
echo " OR"
echo
echo "=> Append the following line to the correct file yourself"
echo
echo " $SOURCE_STR"
echo
echo "=> Close and reopen your terminal afterwards to start using NVM"
exit
else
if not grep -qc 'nvm.fish' "$PROFILE"
echo "=> Appending source string to $PROFILE"
echo "" >> "$PROFILE"
echo $SOURCE_STR >> "$PROFILE"
else
echo "=> Source string already in $PROFILE"
end
end
echo "=> Close and reopen your terminal to start using NVM"