@@ -20,25 +20,32 @@ case $SHELL in
20
20
(* " zsh" ) shell_init=$HOME /.zshrc ;;
21
21
(* " bash" ) shell_init=$HOME /.bashrc ;;
22
22
esac
23
- spyder_exe=$( echo ${PREFIX} /envs/* /bin/spyder)
23
+ spy_exe=$( echo ${PREFIX} /envs/* /bin/spyder)
24
+ u_spy_exe=${PREFIX} /uninstall-spyder.sh
24
25
25
-
26
- if [[ ! -e " $spyder_exe " ]]; then
27
- echo " $spyder_exe not found. Alias not created."
26
+ if [[ ! -e " $spy_exe " ]]; then
27
+ echo " $spy_exe not found. Alias not created."
28
28
elif [[ -z " $shell_init " ]]; then
29
29
echo " Aliasing for $SHELL not implemented."
30
30
else
31
31
echo " Aliasing Spyder's executable in $shell_init ..."
32
- sed -i " /alias spyder=/{h;s|=.*|=${spyder_exe} |};\$ {x;/^$/{s||\nalias spyder=${spyder_exe} |;H};x}" $shell_init
32
+ m1=" # <<<< Added by Spyder <<<<"
33
+ m2=" # >>>> Added by Spyder >>>>"
34
+ new_text=" $m1 \nalias spyder=${spy_exe} \nalias uninstall-spyder=${u_spy_exe} \n$m2 "
35
+ sed -i " /$m1 /,/$m2 /{h;/$m2 / s|.*|${new_text} |; t; d};\$ {x;/^$/{s||\n${new_text} |;H};x}" $shell_init
33
36
fi
34
37
35
38
echo " Creating uninstall script..."
36
- cat << EOF > ${PREFIX} /uninstall.sh
39
+ cat << EOF > ${u_spy_exe}
37
40
#!/bin/bash
38
41
rm -rf ${shortcut_path}
39
42
rm -rf ${PREFIX}
40
43
EOF
41
- chmod +x ${PREFIX} /uninstall.sh
44
+ if [[ -n " $shell_init " ]]; then
45
+ # Remove aliases from shell startup
46
+ echo " sed -i '/$m1 /,/$m2 /d' $shell_init " >> ${u_spy_exe}
47
+ fi
48
+ chmod +x ${u_spy_exe}
42
49
43
50
cat << EOF
44
51
@@ -56,7 +63,7 @@ $ spyder
56
63
57
64
To uninstall Spyder, you need to run from the following from the command line:
58
65
59
- $ ${PREFIX} / uninstall.sh
66
+ $ uninstall-spyder
60
67
61
68
###############################################################################
62
69
0 commit comments