diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2020-01-17 12:16:49 +0100 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2020-01-17 12:16:49 +0100 |
commit | 4ef14d855be8f6a56e05483a34f572d5b8c2f151 (patch) | |
tree | d3b89dde7a5e6ed26011a0496f4e3ecf5040e404 /bin | |
parent | f1524969f404fff4e79ae631db2db3865dc5be15 (diff) | |
download | dotfiles-4ef14d855be8f6a56e05483a34f572d5b8c2f151.tar.gz dotfiles-4ef14d855be8f6a56e05483a34f572d5b8c2f151.zip |
Updated vimconf, and made som bash scripts
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/j | 63 | ||||
-rwxr-xr-x | bin/scps | 28 |
2 files changed, 91 insertions, 0 deletions
@@ -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" |