2013-01-18 18:13:16 +01:00
|
|
|
# Options
|
|
|
|
set -o shwordsplit
|
|
|
|
|
|
|
|
|
2013-01-17 14:59:21 +01:00
|
|
|
# Aliases
|
|
|
|
alias zz='source ~/.zshrc'
|
|
|
|
alias vz='vim ~/.zshrc && source ~/.zshrc'
|
2013-01-17 15:04:45 +01:00
|
|
|
alias vp='vim $ZSH/plugins/david.zsh && source ~/.zshrc'
|
|
|
|
alias vt='vim $ZSH/themes/david.zsh && source ~/.zshrc'
|
2013-01-17 14:59:21 +01:00
|
|
|
alias vi="vim"
|
|
|
|
alias vless="/usr/share/vim/vim73/macros/less.sh"
|
|
|
|
alias publish="python2 -m SimpleHTTPServer"
|
2013-06-19 15:17:10 +02:00
|
|
|
alias curzon="ssh -l david localhost -p 2222"
|
2013-06-20 18:59:49 +02:00
|
|
|
alias push="git push origin master"
|
|
|
|
alias pull="git pull origin master"
|
2013-01-17 14:59:21 +01:00
|
|
|
|
|
|
|
# Functions
|
|
|
|
vncconnect()
|
|
|
|
{
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
echo "usage: vncconnect <remote-ip>"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
hostname=$1
|
|
|
|
echo "digging ssh tunnel to $hostname"; sleep 1
|
|
|
|
ssh $hostname -L 8900/localhost/5901 "sleep 05 && exit" &
|
|
|
|
sleep 02
|
|
|
|
vncviewer localhost:8900
|
|
|
|
echo "killed ssh tunnel to $hostname and ended vnc session"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
rdp()
|
|
|
|
{
|
|
|
|
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
echo -e "server: \c"
|
|
|
|
read server
|
|
|
|
else
|
|
|
|
server=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "username [hubertus]: \c"
|
|
|
|
read username
|
|
|
|
if [ -z $username ]; then
|
|
|
|
username="hubertus"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "domain [aec.at]: \c"
|
|
|
|
read domain
|
|
|
|
if [ -z $domain ]; then
|
|
|
|
domain="aec.at"
|
|
|
|
fi
|
|
|
|
|
2013-05-18 22:59:08 +02:00
|
|
|
rdesktop -u $username -p - -d $domain -g 1280x960 $server
|
2013-01-17 14:59:21 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 15:50:16 +02:00
|
|
|
pullmyzsh()
|
2013-01-17 14:59:21 +01:00
|
|
|
{
|
2013-01-17 15:04:45 +01:00
|
|
|
cd $ZSH
|
2013-01-17 14:59:21 +01:00
|
|
|
git pull origin master
|
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
2013-06-20 15:50:16 +02:00
|
|
|
pushmyzsh()
|
2013-01-17 14:59:21 +01:00
|
|
|
{
|
|
|
|
|
2013-01-17 15:04:45 +01:00
|
|
|
cd $ZSH
|
2013-01-19 10:36:35 +01:00
|
|
|
git add **/*[^lastrun]
|
2013-01-17 15:04:45 +01:00
|
|
|
git commit -am "pushzshconfig $(date "+%d.%m.%Y %H:%M")"
|
2013-01-17 14:59:21 +01:00
|
|
|
git push origin master
|
|
|
|
cd -
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-18 18:01:33 +01:00
|
|
|
update()
|
|
|
|
{
|
2013-01-18 18:13:16 +01:00
|
|
|
|
2013-01-18 18:01:33 +01:00
|
|
|
#checking for system
|
2013-01-18 18:13:16 +01:00
|
|
|
systems="ubuntu arch"
|
2013-01-18 18:01:33 +01:00
|
|
|
issue="$(cat /etc/issue)"
|
2013-06-20 17:22:30 +02:00
|
|
|
if [ -z $issue ]; then
|
|
|
|
echo "unknown system (/etc/issue is empty). could not run update."
|
2013-06-20 17:36:28 +02:00
|
|
|
else
|
|
|
|
for item in $systems; do
|
|
|
|
echo $issue | grep -i $item >> /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
system=$item
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
case $system in
|
|
|
|
ubuntu)
|
|
|
|
sudo apt-get update && sudo apt-get dist-upgrade
|
|
|
|
;;
|
|
|
|
arch)
|
|
|
|
sudo pacman -Syu
|
|
|
|
;;
|
|
|
|
?)
|
|
|
|
echo "unknown system. could not run update."
|
|
|
|
;;
|
|
|
|
esac
|
2013-06-20 17:22:30 +02:00
|
|
|
fi
|
2013-01-18 18:01:33 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-18 23:27:24 +01:00
|
|
|
is_dirty() {
|
|
|
|
local SUBMODULE_SYNTAX=''
|
|
|
|
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
|
|
|
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
|
|
|
fi
|
|
|
|
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-18 19:31:32 +01:00
|
|
|
info()
|
|
|
|
{
|
2013-01-18 21:41:21 +01:00
|
|
|
echo -e "hostname: $(hostname)"
|
|
|
|
echo -e "dns server(s): "
|
|
|
|
nameservers=$(cat /etc/resolv.conf | grep --color=never nameserver | awk '{print $2}')
|
|
|
|
for server in $nameservers; do
|
|
|
|
echo -e "$server"
|
|
|
|
done
|
|
|
|
|
|
|
|
devices=$(ip link | awk '/^[0,2-9]*:/ {print $2}' | sed -e 's/: / /g' | sed -e 's/://g')
|
|
|
|
for device in $devices; do
|
|
|
|
ips=$(ip -f inet addr show dev $device | awk '/inet/ {print $2}')
|
|
|
|
echo -e "$device:"
|
|
|
|
for ip in $ips; do
|
|
|
|
echo -e "$ip, \c"
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
#ip -f inet addr | grep inet | grep -v 127.0.0.1 | awk {'print $2'}
|
|
|
|
#ip -f inet6 addr | grep inet6 | grep -v "::1/128" | grep -v "fe80:" | awk '{print $2}'
|
2013-01-18 19:31:32 +01:00
|
|
|
}
|