Commit f614be55 authored by david's avatar david 💬

added first plugin

parent 4c9b2654
......@@ -38,3 +38,7 @@ curl -xyz https://socialg.it/david/dotfiles/install.sh; bash install.sh
- script to disable owncloud/nextcloud in miab
- also maybe enforce dmarc (spf/dkim)
- patch -p 22 in backup script (or make a pr)
## References
* https://github.com/sindresorhus/pure
#!/bin/bash
# Basic installer for my personal dotfiles.
# Basic install/update script for my personal dotfiles.
# author: david@socialnerds.org
# license: MIT
......@@ -9,7 +9,8 @@
# **** vars ****
command="$0"
root="$HOME/.dotfiles"
logfile="$HOME/.dotfiles.log"
#logfile="$root/dotfiles.log"
functions="$root/zfunctions"
timestamp=$(date +"%Y%m%d%H%M")
repo="https://socialg.it/david/dotfiles.git"
debug=1
......@@ -33,7 +34,7 @@ message() {
return 1
fi
echo -e [$level] ${@:2}
echo -e [$timestamp][$command][$1] ${@:2} >> $logfile
#echo -e [$timestamp][$command][$1] ${@:2} >> $logfile
sleep 0.1
}
......@@ -41,45 +42,67 @@ failsafe() {
if [ $1 -ne 0 ]; then
message e "Installer died horribly!"
if [ $2 ]; then
message d "Dumping last output to logfile[$logfile] and stdout."
echo ${@:2} | tee -a $logfile
message d "Dumping last output to stdout."
#echo ${@:2} | tee -a $logfile
echo ${@:2}
fi
exit 1
fi
}
# **** debugging/testing stuff ****
#rm -rf $root*
#ln -s $HOME/Git/dotfiles $root
cleanup() {
# Get rid of preexisting data at destination
destination=$1
if [ -a "$destination.old" ]; then
message e "A previous backup exists. Move elsewhere or delete first[$destination.old]."
exit 1
else
if [ -h $destination ]; then
link=$(ls -la $destination | awk '{print $9" "$10" "$11}')
# It should be safe to just remove symbolic links because no data is actually deleted.
message d "Symbolic link exists, attempting to remove it[$link]."
output=""; output=$(rm $destination 2>&1); failsafe $? $output
message i "Removed symbolic link[$link]."
elif [ -a $destination ]; then
# Rename data to $destination.old
message d "Data exists at install destination, attempting to create a backup[$destination.old]."
output="", output=$(mv $destination $destination.old 2>&1); failsafe $? $output
message i "Created a backup of a preexisting data[$destination.old]."
fi
fi
}
# **** start of script ****
message d "Warming up dotfiles installer."
message d "Initiating preflight checks."
#message d "Initiating preflight checks."
# check if logfile exists and is writeable, if not try to create it with failsafe
# check dependencies, try to install missing with failsafe
# (awk tee ls git wget/curl rm mv sleep date)
# check for preexisting data at install destination, get rid of it
if [ -h $root ]; then
link=$(ls -la $root | awk '{print $9" "$10" "$11}')
# It should be safe to just remove symbolic links because no data is actually deleted.
message d "Symbolic link exists at the install destination, attempting to remove it[$link]."
output=$(rm $root 2>&1); failsafe $? $output
message i "Removed symbolic link at the install destination."
elif [ -a $root ]; then
message d "Data exists at install destination, attempting to create a backup[$root.old.$timestamp]."
output=$(mv $root $root.old.$timestamp 2>&1); failsafe $? $output
message i "Created a backup of a preexisting folder at the install destination[$root.old.$timestamp]."
fi
# clone dotfiles
# download dotfiles
cleanup "$root"
message d "Attempting to clone git repository[$repo] into $root."
output=$(git clone $repo $root 2>&1); failsafe $? $output
output=""; output=$(git clone $repo $root 2>&1); failsafe $? $output
message i "Cloned git repository into $root."
# create zshfunctions folder [.zfunctions]
cleanup $functions
output=""; output=$(mkdir -p $functions 2>&1); failsafe $? $output
message i "Created functions folder[$functions]."
# download pure
output=""; output=$(wget https://github.com/sindresorhus/pure/blob/master/pure.zsh -o $functions/pure.zsh 2>&1); failsafe $? $output
output=""; output=$(wget https://github.com/sindresorhus/pure/blob/master/async.zsh -o $functions/async.zsh 2>&1); failsafe $? $output
message i "Downloaded ZSH plugins into functions folder[$functions]."
# link .zshrc
cleanup "$HOME/.zshrc"
output=""; output=$(ln -s $root/zsh/zshrc $HOME/.zshrc 2>&1); failsafe $? $output
message i "Linked .zshrc."
message d "Installer finished."
......
# Options
set -o shwordsplit
# Aliases
alias zz='source ~/.zshrc'
alias vz='vim ~/.zshrc && source ~/.zshrc'
#alias vp='vim $ZSH/plugins/david.zsh && source ~/.zshrc'
#alias vt='vim $ZSH/themes/david.zsh && source ~/.zshrc'
#alias vs='vim $ZSH/myzsh.sh && source ~/.zshrc'
#alias vu='cd $ZSH > /dev/null; git pull origin master; cd - > /dev/null; echo $timestamp > $ZSH/lastrun; source ~/.zshrc'
alias vi='vim'
alias v='vim'
alias serve="python2 -m SimpleHTTPServer"
alias push="git push origin master"
alias pull="git pull origin master"
alias commit="git commit -a"
#alias vpn="sudo openvpn --writepid /var/run/openvpn --config /home/david/.vpn/david.conf"
alias aec="sshuttle -vvr 90.146.8.233 192.168.6.0/24 90.146.8.0/26 10.9.0.0/26 10.12.0.0/16 10.2.0.0/26 192.168.3.0/24 10.12.4.0/22"
alias home="sshuttle -vvr stargazer.socialnerds.org:2222 10.1.0.0/16"
alias dmz="sshuttle -vvr 90.146.8.9 90.146.8.0/26"
alias c="clear"
alias start_vmware="~/Git/scripts/start_vmware.sh"
alias ls='ls --color=auto'
alias pacrepo='sudo reflector -l 20 -f 10 --save /etc/pacman.d/mirrorlist'
alias pacman='sudo pacman'
alias journalctl='sudo journalctl'
alias pacu='sudo pacman -Syu --noconfirm'
alias auru='yaourt -Syua --noconfirm'
alias systemctl='sudo systemctl'
alias se='ls /usr/bin | grep'
# Variables
export EDITOR=vim
if [[ $LANG = '' ]]; then
export LANG=en_US.UTF-8
fi
# Functions
rdp()
{
if [ -z $1 ]; then
echo -e "server: \c"
read server
else
server=$1
fi
echo -e "username [davidadm]: \c"
read username
if [ -z $username ]; then
username="davidadm"
fi
echo -e "domain [aec.at]: \c"
read domain
if [ -z $domain ]; then
domain="aec.at"
fi
which rdesktop >/dev/null
if [ $? -eq 0 ]; then
#rdesktop -u $username -p - -d $domain -g 1366x768 $server -k de
rdesktop -K -u $username -p - -d $domain -g workarea $server -k de
else
which xfreerdp >/dev/null
if [ $? -eq 0 ]; then
#xfreerdp +clipboard /v:$server /u:$username /d:$domain /size:1920x1080
xfreerdp /v:$server /u:$username /d:$domain /size:1366x768 -wallpaper:on
else
echo "error: no rdp client found"
return 1
fi
fi
}
update()
{
# OS Upgrade function for various systems.
#checking for system
systems="ubuntu arch solus raspbian antergos"
issue="$(cat /etc/issue)"
for item in $systems; do
echo $issue | grep -i $item >> /dev/null
if [ $? -eq 0 ]; then
system=$item
fi
done
#trying to update parsed system
case $system in
ubuntu|debian|raspbian)
echo "Updating Ubuntu/Debian.."
sudo apt-get update && sudo apt-get dist-upgrade
;;
arch|antergos)
echo "Updating Arch Linux.."
sudo pacman -Syu
;;
solus)
echo "Updating Solus OS.."
sudo eopkg update-repo && sudo eopkg upgrade
;;
?)
echo "error: unknown system."
return 1
;;
esac
if [ $? -ne 0 ]; then
echo "error: something went wrong."
return 1
fi
}
install()
{
#checking for system
systems="ubuntu arch"
issue="$(cat /etc/issue)"
packages=$*
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 install -y $packages
;;
arch)
sudo pacman -Sy --noconfirm $packages
;;
?)
echo "unknown system. could not run install."
;;
esac
}
fixtrackpoint()
{
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation" 1
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Button" 2
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 200
xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5
xinput set-prop "TPPS/2 IBM TrackPoint" "Device Accel Constant Deceleration" 0.75
}
# check for default shell
cat /etc/passwd | grep ~ | grep "/bin/zsh" > /dev/null
if [ $? -eq 1 ]; then
echo "You should set me as your default shell."
fi
# load plugins
# pure & zfunctions
fpath=("$HOME/.dotfiles/zfunctions" $fpath)
autoload -U promptinit; promptinit
prompt pure
# path
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment