-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.sh
executable file
·116 lines (104 loc) · 4.73 KB
/
install.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
restart_nautilus()
{
read -p "Do you want restart Nautilus (Files) [Y/n]? " VAR
if [[ $VAR = 'y' || $VAR = 'Y' ]]; then
nautilus -q
fi
}
cp_file() {
FILE=vscode-nautilus.py
TARGDIR=$1
if [[ ! -d $TARGDIR ]]; then
mkdir -v -p "$TARGDIR"
fi
cp -v "$FILE" "$TARGDIR"
set_location
restart_nautilus
}
cp_file_sudo() {
FILE=vscode-nautilus.py
TARGDIR=$1
if [[ ! -d $TARGDIR ]]; then
sudo mkdir -v -p "$TARGDIR"
fi
sudo cp -v "$FILE" "$TARGDIR"
set_location
restart_nautilus
}
set_location() {
# VSCode
if [[ -e "/usr/bin/code" ]]; then
echo "VSCode is installed in /usr/bin/code"
sed -i "s|COMMAND_REPLACE|/usr/bin/code|g" $TARGDIR/vscode-nautilus.py
sed -i "s|INSTALL_PATH_REPLACE|/usr/bin/code|g" $TARGDIR/vscode-nautilus.py
# VSCode Insiders
elif [[ -e "/usr/bin/code-insiders" ]]; then
echo "VSCode is installed in /usr/bin/code-insiders"
sed -i "s|COMMAND_REPLACE|/usr/bin/code-insiders|g" $TARGDIR/vscode-nautilus.py
sed -i "s|INSTALL_PATH_REPLACE|/usr/bin/code-insiders|g" $TARGDIR/vscode-nautilus.py
# VSCode installed with Snap
elif [[ -e "/snap/bin/code" ]]; then
echo "VSCode is installed in /snap/bin/code"
sed -i "s|COMMAND_REPLACE|/snap/bin/code|g" $TARGDIR/vscode-nautilus.py
sed -i "s|INSTALL_PATH_REPLACE|/snap/bin/code|g" $TARGDIR/vscode-nautilus.py
# VSCode installed with Flatpak
elif [[ -e "/var/lib/flatpak/app/com.visualstudio.code/current/active/files/bin/code" ]]; then
echo "VSCode is installed with Flatpak"
sed -i "s|COMMAND_REPLACE|flatpak run com.visualstudio.code|g" $TARGDIR/vscode-nautilus.py
sed -i "s|INSTALL_PATH_REPLACE|/var/lib/flatpak/app/com.visualstudio.code/current/active/files/bin/code|g" $TARGDIR/vscode-nautilus.py
# VSCodium
elif [[ -e "/usr/bin/codium" ]]; then
echo "VSCodium is installed in /usr/bin/codium"
sed -i "s|COMMAND_REPLACE|/usr/bin/codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|INSTALL_PATH_REPLACE|/usr/bin/codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|Open in Code|Open in Codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|Open this folder/file in VSCode|Open this folder/file in VSCodium|g" $TARGDIR/vscode-nautilus.py
# VSCodium installed with Snap
elif [[ -e "/snap/bin/codium" ]]; then
echo "VSCodium is installed in /snap/bin/codium"
sed -i "s|COMMAND_REPLACE|/snap/bin/codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|INSTALL_PATH_REPLACE|/snap/bin/codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|Open in Code|Open in Codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|Open this folder/file in VSCode|Open this folder/file in VSCodium|g" $TARGDIR/vscode-nautilus.py
# VSCodium installed with Flatpak
elif [[ -e "/var/lib/flatpak/app/com.vscodium.codium/current/active/files/bin/codium" ]]; then
echo "VSCodium is installed with Flatpak"
sed -i "s|COMMAND_REPLACE|flatpak run com.vscodium.codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|INSTALL_PATH_REPLACE|/var/lib/flatpak/app/com.vscodium.codium/current/active/files/bin/codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|Open in Code|Open in Codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|Open this folder/file in VSCode|Open this folder/file in VSCodium|g" $TARGDIR/vscode-nautilus.py
# If none of the above, ask user to enter the path
else
echo "Could not find VSCode/VSCodium installation path"
read -p "Please enter the path to VSCode/VSCodium : " VAR
sed -i "s|/usr/bin/code|${VAR}|g" $TARGDIR/vscode-nautilus.py
if [[ ${VAR} =~ "codium" ]]; then
sed -i "s|Open in Code|Open in Codium|g" $TARGDIR/vscode-nautilus.py
sed -i "s|Open this folder/file in VSCode|Open this folder/file in VSCodium|g" $TARGDIR/vscode-nautilus.py
fi;
fi
}
if [[ $UID != 0 ]]; then
read -p "This script is running without sudo, install for current user [y/N]? " VAR
if [[ $VAR = 'y' || $VAR = 'Y' ]]; then
TARGDIR=~/.local/share/nautilus-python/extensions
cp_file "$TARGDIR"
else
read -p "Do you want install for all user [y/N]? " VAR
if [[ $VAR = 'y' || $VAR = 'Y' ]]; then
TARGDIR=/usr/share/nautilus-python/extensions
cp_file_sudo "$TARGDIR"
else
echo "Install failed!"
fi
fi
else
read -p "This script is running with sudo, install for all user [y/N]? " VAR
if [[ $VAR = 'y' || $VAR = 'Y' ]]; then
TARGDIR=/usr/share/nautilus-python/extensions
cp_file "$TARGDIR"
else
echo "Install failed!"
fi
fi