-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
69 lines (59 loc) · 2.28 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
#!/bin/sh
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
flouser=$(logname)
echo "Installing Nushell config defaults..."
if [ ! -e /home/${flouser}/.config/nushell ]; then mkdir /home/${flouser}/.config/nushell; fi
cp include/config.nu /home/${flouser}/.config/nushell/
cp include/env.nu /home/${flouser}/.config/nushell/
touch /home/${flouser}/.config/nushell/history.txt
echo "Installing mimetypes for .nu files..." # this is continuously adding the same entries to /etc/mime.types and have to be fixed
cat >> /etc/mime.types <<EOF
application/x-nu nu
EOF
#-<- should check if line is already added, before re-adding!
cat > /usr/share/mime/packages/x-nu.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-nu">
<comment>Nushell script</comment>
<generic-icon name="application-x-nu"/>
<glob pattern="*.nu"/>
</mime-type>
</mime-info>
EOF
sudo update-mime-database /usr/share/mime
echo "Installing icons for .nu files..."
cd include/icons
cp -r -f --preserve=all . /usr/share/icons/hicolor/scalable/mimetypes/
cd "$SCRIPTPATH"
sudo gtk-update-icon-cache /usr/share/icons/gnome/ -f
echo "Installing handler for .nu files..."
echo "Installing nu-script-handler..."
sudo cp -f nu-script-handler /usr/bin/nu-script-handler
echo "Installing shortcut in /usr/share/applications..."
cat > /usr/share/applications/nu-script-handler.desktop <<EOF
[Desktop Entry]
Type=Application
Name=Nu Script Handler
Exec=nu-script-handler %f
Icon=application-x-executable
StartupNotify=false
MimeType=application-x-nu;
NoDisplay=true
EOF
echo "Turning nu-script-handler into the default program (to user $flouser) for .nu scripts..."
cat >> /home/$flouser/.config/mimeapps.list <<EOF
application/x-nu=nu-script-handler.desktop
EOF
#-<- should check if line is already added, before re-adding!
installfail(){
echo "Installation has failed."
exit 1
}
if [ -f /usr/bin/nu-script-handler ];then
echo "- Turning nu-script-handler into an executable..."
sudo chmod +x /usr/bin/nu-script-handler
if nu-script-handler babyisalive; then echo "Done! Running 'nu-script-handler' command as example to use it:" && (nu-script-handler &);exit 0; else installfail; fi
else
installfail
fi