From 4ef14d855be8f6a56e05483a34f572d5b8c2f151 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Fri, 17 Jan 2020 12:16:49 +0100 Subject: Updated vimconf, and made som bash scripts --- Common/vim/vim | 1 + Common/vimrc | 1 + bin/j | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ bin/scps | 28 ++++++++++++++++++++++ install/install_mac.sh | 1 + mac/zshrc | 9 ++++++-- 6 files changed, 101 insertions(+), 2 deletions(-) create mode 120000 Common/vim/vim create mode 100755 bin/j create mode 100755 bin/scps diff --git a/Common/vim/vim b/Common/vim/vim new file mode 120000 index 0000000..f81b69e --- /dev/null +++ b/Common/vim/vim @@ -0,0 +1 @@ +/Users/jakobstendahl/_code/Personal projects/dotfiles/Common/vim \ No newline at end of file diff --git a/Common/vimrc b/Common/vimrc index 600b81c..c2d766c 100644 --- a/Common/vimrc +++ b/Common/vimrc @@ -183,6 +183,7 @@ set smarttab " 1 tab == 4 spaces set shiftwidth=4 set tabstop=4 +set softtabstop=4 " Linebreak on 500 characters set lbr 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" diff --git a/install/install_mac.sh b/install/install_mac.sh index e4d5a9a..d26ed16 100755 --- a/install/install_mac.sh +++ b/install/install_mac.sh @@ -70,6 +70,7 @@ dlgYN "> Create symlinks" res if [ $res -eq 1 ]; then CWD=$(PWD) tput sc + ln -isf "$CWD/bin" ~/bin ln -isf "$CWD/mac/zshrc" ~/.zshrc ln -isf "$CWD/mac/tmux.conf" ~/.tmux.conf ln -isf "$CWD/mac/Hyperterm/hyper.js" ~/.hyper.js diff --git a/mac/zshrc b/mac/zshrc index 82bcc79..efd0cab 100644 --- a/mac/zshrc +++ b/mac/zshrc @@ -64,12 +64,13 @@ export LANG=en_US.UTF-8 path+=("/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands") export PATH export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/opt/local/bin:/opt/local/sbin - +path+=("$(readlink /Users/$DEFAULT_USER/bin)") +export path alias lamp='/Users/jakobstendahl/.lamp.sh' alias uio-linux='ssh -YC jakobste@login.ifi.uio.no' alias uio-send='scp $1 jakobste@login.ifi.uio.no:/uio/hume/student-u27/jakobste/Downloads/' -alias uio-get='scp jakonste@login.ifi.uio.no:/uio/hume/student-u27/jakobste/$1 .' +alias uio-get='scp jakobste@login.ifi.uio.no:/uio/hume/student-u27/jakobste/$1 .' alias krak='/Applications/GitKraken.app/Contents/MacOS/GitKraken -p "$(PWD)" &>> /dev/null &' alias lsp="ps -ax | grep" alias lsa="ls -la" @@ -86,3 +87,7 @@ man() { } clear + +#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! +export SDKMAN_DIR="/Users/jakobstendahl/.sdkman" +[[ -s "/Users/jakobstendahl/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/jakobstendahl/.sdkman/bin/sdkman-init.sh" -- cgit v1.2.3