-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·51 lines (47 loc) · 2.04 KB
/
init.sh
File metadata and controls
executable file
·51 lines (47 loc) · 2.04 KB
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
#!/bin/bash
ONEKEY_ENV_PATH=`(pwd)`
. $ONEKEY_ENV_PATH/sh/function.sh
. $ONEKEY_ENV_PATH/sh/color.sh
sysType=$(uname -s)
case $sysType in
"Linux")
isStringInFile ONEKEY_ENV_PATH ~/.profile
if [ $? = 0 ]; then
echo export ONEKEY_ENV_PATH="$ONEKEY_ENV_PATH" >> ~/.profile && echo 'export PATH="$PATH:$ONEKEY_ENV_PATH/bin"' >> ~/.profile
fi
source ~/.profile
;;
"Darwin")
shellType=`echo $SHELL`
$OUTPUT "current shell type is $shellType..."
if [[ $shellType =~ "bash" ]] || [[ $shellType =~ "-bash" ]]; then
isStringInFile ONEKEY_ENV_PATH ~/.bashrc
if [ $? = 0 ]; then
echo export ONEKEY_ENV_PATH="$ONEKEY_ENV_PATH" >> ~/.bashrc && echo 'export PATH="$PATH:$ONEKEY_ENV_PATH/bin"' >> ~/.bashrc
fi
$OUTPUT "ONEKEY_ENV_PATH has been set to environment file ~/.bashrc..."
source ~/.bashrc
elif [[ $shellType =~ "zsh" ]] || [[ $shellType =~ "-zsh" ]]; then
if [ ! -f ~/.zshrc.pre-oh-my-zsh ]; then
isStringInFile ONEKEY_ENV_PATH ~/.zshrc
if [ $? = 0 ]; then
echo export ONEKEY_ENV_PATH="$ONEKEY_ENV_PATH" >> ~/.zshrc && echo 'export PATH="$PATH:$ONEKEY_ENV_PATH/bin"' >> ~/.zshrc
fi
$OUTPUT "ONEKEY_ENV_PATH has been set to environment file ~/.zshrc..."
else
isStringInFile ONEKEY_ENV_PATH ~/.zshrc.pre-oh-my-zsh
if [ $? = 0 ]; then
echo export ONEKEY_ENV_PATH="$ONEKEY_ENV_PATH" >> ~/.zshrc.pre-oh-my-zsh && echo 'export PATH="$PATH:$ONEKEY_ENV_PATH/bin"' >> ~/.zshrc.pre-oh-my-zsh && zsh && ~/.zshrc
fi
$OUTPUT "ONEKEY_ENV_PATH has been set to environment file ~/.zshrc.pre-oh-my-zsh..."
fi
source ~/.zshrc
fi
;;
*)
$OUTPUT "system $sysType not supported!"
exit -1
;;
esac
$OUTPUT "Seting Env ONEKEY_ENV_PATH $ONEKEY_ENV_PATH successfully..."
onekey help