-#!/bin/sh
-cd /tmp
-curl ftp://ftp.cs.ru.nl/pub/Clean/builds/linux-x64/clean-bundle-complete-linux-x64-latest.tgz | tar -xz
-rm -rf /opt/clean
-mv clean-bundle-complete /opt/clean
+#!/bin/bash
+set -e
+DISTRO="https://ftp.cs.ru.nl/Clean/builds/linux-x64/clean-bundle-complete-linux-x64-latest.tgz"
+TAGS="https://gitlab.science.ru.nl/cloogle/cloogle-tags/-/jobs/artifacts/master/raw/cloogletags?job=build"
+CLEAN_HOME="${CLEAN_HOME:-/opt/clean}"
+
+echo "Cleaning up the old distro"
+rm -rf "$CLEAN_HOME"/*
+echo "Downloading clean"
+curl -sS "$DISTRO" | tar -C "$CLEAN_HOME" --strip-components=1 -xz
+echo "Downloading cloogletags"
+curl -sSLo "$CLEAN_HOME"/bin/cloogletags "$TAGS"
+chmod +x "$CLEAN_HOME"/bin/cloogletags
+echo "Generating tags"
+cloogletags -a -c -d "$CLEAN_HOME"/lib -o "$CLEAN_HOME"/lib/tags 2>/dev/null
+
+echo "Patching StdEnv for binumap"
patch /opt/clean/lib/StdEnv/StdGeneric.dcl <<EOPATCH
--- StdGeneric.dcl 2018-12-17 02:43:55.000000000 +0100
+++ StdGeneric.dcl 2018-12-17 11:06:09.196234236 +0100
| is_id f
EOPATCH
+echo "Adding the iTasks-git environment"
patch /opt/clean/etc/IDEEnvs <<EOPATCH
--- IDEEnvs 2018-12-17 11:58:48.876039159 +0100
+++ IDEEnvs 2018-12-17 12:00:52.384066455 +0100
export CLEAN_HOME=/opt/clean
-export PATH=~/.local/bin:$PATH
-export PATH=$PATH:$CLEAN_HOME/lib/exe:$CLEAN_HOME/bin
-export PATH=$PATH:/opt/texlive/2018/bin/x86_64-linux:/opt/zotero:/opt/arduino
+export PATH="~/.local/bin:$PATH"
+export PATH="$PATH:$CLEAN_HOME/lib/exe:$CLEAN_HOME/bin"
+export PATH="$PATH:/opt/texlive/2018/bin/x86_64-linux:/opt/zotero:/opt/arduino:/opt/beets/bin"
export GTK_IM_MODULE=xim
export QT_IM_MODULE=xim
# vi copy and pasting
bind-key -T copy-mode-vi 'v' send -X begin-selection
-bind-key -T copy-mode-vi 'y' send -X copy-selection
+bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
bind-key -T copy-mode-vi 'Space' send -X halfpage-down
bind-key -T copy-mode-vi 'Bspace' send -X halfpage-up
nnoremap n nzzzv
nnoremap N Nzzzv
+" Allow yanking to the clipboards in visual mode
+vnoremap sy :w ! xclip<enter><enter>
+vnoremap cy :w ! xclip -sel clip<enter><enter>
+" Allow pasting from the clipboards in normal mode
+nnoremap sp :r ! xclip -o<enter>
+nnoremap cp :r ! xclip -sel clip -o<enter>
+
" Disable ex mode
map Q <Nop>