Skip to content

Commit 263a092

Browse files
committed
Alias uninstall-spyder.sh in shell startup file
Remove aliases from shell startup file in uninstall-spyder.sh
1 parent 009c50d commit 263a092

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

installers-conda/resources/post-install.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,32 @@ case $SHELL in
2020
(*"zsh") shell_init=$HOME/.zshrc ;;
2121
(*"bash") shell_init=$HOME/.bashrc ;;
2222
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
2425

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."
2828
elif [[ -z "$shell_init" ]]; then
2929
echo "Aliasing for $SHELL not implemented."
3030
else
3131
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
3336
fi
3437

3538
echo "Creating uninstall script..."
36-
cat <<EOF > ${PREFIX}/uninstall.sh
39+
cat <<EOF > ${u_spy_exe}
3740
#!/bin/bash
3841
rm -rf ${shortcut_path}
3942
rm -rf ${PREFIX}
4043
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}
4249

4350
cat <<EOF
4451
@@ -56,7 +63,7 @@ $ spyder
5663
5764
To uninstall Spyder, you need to run from the following from the command line:
5865
59-
$ ${PREFIX}/uninstall.sh
66+
$ uninstall-spyder
6067
6168
###############################################################################
6269

0 commit comments

Comments
 (0)