aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/j63
-rwxr-xr-xbin/scps28
2 files changed, 91 insertions, 0 deletions
diff --git a/bin/j b/bin/j
new file mode 100755
index 0000000..65abad6
--- /dev/null
+++ b/bin/j
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+function dlgYN() {
+ tput sc
+ tput setaf 4
+ printf "$1 (y/n)? "
+ while :
+ do
+ read -n 1 -p "" YNQuestionAnswer
+ if [[ $YNQuestionAnswer == "y" ]]; then
+ tput rc; tput el
+ tput sc
+ eval $2=1 # Set parameter 2 of input to the return value
+ break
+ elif [[ $YNQuestionAnswer == "n" ]]; then
+ tput rc; tput el
+ printf ". $1?: \e[0;31mNo\e[0m\n"
+ eval $2=0 # Set parameter 2 of input to the return value
+ break
+ fi
+ done
+}
+
+function die() {
+ tput setaf 1
+ echo "$1"
+ tput sgr0
+ exit 1
+}
+
+if [ -z $1 ]; then
+ tput setaf 1
+ echo "You need to provide a file";
+ tput sgr0
+ exit 1
+fi
+
+tput setaf 1
+if [[ $1 == *.java ]]; then
+ echo "WARN: You probably didn't mean to end the filename with \".java\"."
+fi
+
+if [[ $1 == *.class ]]; then
+ echo "WARN: You probably didn't mean to end the filename with \".class\"."
+fi
+tput sgr0
+
+
+tput setaf 4
+echo "> javac $1.java "
+tput sgr0
+
+javac "$1.java" || die "Error while trying to compile."
+
+
+dlgYN "Run \"$1\"?" res
+if [ $res -eq 1 ]; then
+ tput setaf 4
+ echo "> java $1"
+ tput sgr0
+
+ java $1 || die "Error while trying to run program."
+fi
diff --git a/bin/scps b/bin/scps
new file mode 100755
index 0000000..f8f9b30
--- /dev/null
+++ b/bin/scps
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+if [ -z $1 ]; then
+ tput setaf 1
+ echo "Server not provided."
+ tput sgr0
+ exit 1
+fi
+
+if [ -z $2 ]; then
+ tput setaf 1
+ echo "File not provided."
+ tput sgr0
+ exit 1
+fi
+
+if [[ -d $2 ]]; then
+ tput setaf 1
+ echo "Cannot move directories..."
+ tput sgr0
+ exit 1
+fi
+
+SERVER="$1"
+FILE="$2"
+SERVERFILE="$(basename $FILE)"
+
+scp "$FILE" "$SERVER":"$SERVERFILE"