-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·35 lines (27 loc) · 958 Bytes
/
build.sh
File metadata and controls
executable file
·35 lines (27 loc) · 958 Bytes
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
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <input-file>"
exit 1
fi
input_file="$1"
if [ ! -f "$input_file" ]; then
echo "Input file $input_file not found"
exit 1
fi
text=$(cat "$input_file")
encoded_text=$(echo "$text" | base64)
# generate the shell script that runs the ruby script with the encoded text as a parameter
cat <<EOF >run.sh
#!/bin/bash
# an awful but needed script to open the default terminal emulator
for terminal in "\$TERMINAL" x-terminal-emulator mate-terminal gnome-terminal terminator xfce4-terminal termite lxterminal terminology st qterminal lilyterm tilix terminix konsole kitty guake tilda alacritty hyper wezterm urxvt rxvt termit Eterm aterm uxterm xterm roxterm ; do
if command -v "\$terminal" > /dev/null 2>&1; then
exec "\$terminal" -e "tail -f console.txt" > /dev/null 2>&1 &
break
fi
done
src=\$(echo "$encoded_text" | base64 -d)
ruby -e "\$src"
EOF
# make script executable
chmod +x run.sh