aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vim/vimrc10
-rwxr-xr-xscripts/rexec.sh72
2 files changed, 81 insertions, 1 deletions
diff --git a/.vim/vimrc b/.vim/vimrc
index 6058881..63b3b30 100644
--- a/.vim/vimrc
+++ b/.vim/vimrc
@@ -88,6 +88,14 @@ nmap <silent> <F6> :TlistToggle<CR>
nmap <silent> gc :tabclose<CR>
nmap <silent> gn :tabnew<CR>:e .<CR>
+" Smart brackets
+inoremap " ""<left>
+inoremap ' ''<left>
+inoremap ( ()<left>
+inoremap [ []<left>
+inoremap { {}<left>
+inoremap {<CR> {<CR>}<ESC>O
+inoremap {;<CR> {<CR>};<ESC>O
" ===========
" COMMANDS
@@ -113,7 +121,7 @@ command -bar Fileheader call Insert_Header(expand("%"))
function Insert_Header(name)
let l:name=systemlist("git config --global --get user.name")[0]
let l:mail=systemlist("git config --global --get user.email")[0]
- call append("0", ["/*", " * ".a:name, " * (c) ".strftime("%Y")." ".l:name." <".l:mail.">", " * License: ", "*/"])
+ call append("0", ["/*", " * ".a:name, " * (c) ".strftime("%Y")." ".l:name." <".l:mail.">", " * License: ", " */"])
startinsert
endfunction
diff --git a/scripts/rexec.sh b/scripts/rexec.sh
new file mode 100755
index 0000000..3efe64d
--- /dev/null
+++ b/scripts/rexec.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+ARGC=$#
+ARGV=($@)
+
+SSH_IDENTITY=~/.ssh/id_rsa
+SSH_PORT=22
+SSH_HOST=
+
+SSH_OPTIONS="-o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=no"
+SSH="ssh $SSH_OPTIONS"
+
+SCRIPT_FILE=
+SCRIPT_INTERPRETER=/bin/sh
+
+function parse_args() {
+ for (( i=0; i < $ARGC;i++ )); do
+ local ARGREGEX="^-.*"
+ if [[ ! ${ARGV[$i]} =~ $ARGREGEX ]]; then
+ [ -z $SSH_HOST ] && SSH_HOST=${ARGV[$i]} && continue
+ [ -z $SCRIPT_FILE ] && SCRIPT_FILE=${ARGV[$i]} && continue
+
+ print_help 1
+ fi
+
+ case ${ARGV[$i]} in
+ -p)
+ i=$((i+1))
+ SSH_PORT=${ARGV[$i]};;
+ -s)
+ i=$((i+1))
+ SSH=${ARGV[$i]} $SSH_OPTIONS;;
+ -i)
+ i=$((i+1))
+ SSH_IDENTITY=${ARGV[$i]};;
+ -h)
+ print_help 0;;
+ *)
+ echo Invalid Argument ${ARGV[$i]}
+ echo $0 -h for help
+ exit 1;;
+ esac
+
+ done
+
+ [ -z $SSH_HOST ] && echo No host specified && exit 1
+ [ -z $SCRIPT_FILE ] && echo No script specified && exit 1
+}
+
+function print_help() {
+ cat << EOF
+Execute a script on a remote host via SSH
+
+Usage:
+$0 [OPTIONS] [USER@]HOST SCRIPT
+ -p <PORT> SSH port (default: 22)
+ -s <SSH> Custom SSH program
+ -i <IDENTITY> SSH Identity file (default: ~/.ssh/id_rsa.pub)
+ -h Print this help text
+EOF
+ exit $1
+}
+
+parse_args
+
+[ ! -f $SCRIPT_FILE ] && echo \"$SCRIPT_FILE\" not found && exit 1
+
+INTERPRETER_STRING=$(head -n 1 $SCRIPT_FILE)
+INTERPRETER_REGEX="^#!.*"
+[[ $INTERPRETER_STRING =~ $INTERPRETER_REGEX ]] && SCRIPT_INTERPRETER=$(tail -c +3 <<< $INTERPRETER_STRING)
+
+cat $SCRIPT_FILE | $SSH -p $SSH_PORT -i $SSH_IDENTITY $SSH_HOST $SCRIPT_INTERPRETER