# My personal ZSH plugin with custom aliases and functions. # It might not be very useful to you. # **** zsh options **** set -o shwordsplit # **** aliases **** alias zz='source $HOME/.zshrc' alias {update_zsh,zu}='echo "LAST_EPOCH=0" > $ZSH_CACHE_DIR/.zsh-custom-update > $ZSH_CACHE_DIR/.zsh-update; source $HOME/.zshrc' alias vz='vim $HOME/.zshrc && source $HOME/.zshrc' alias vp='vim $ZSH_CUSTOM/plugins/zsh-david/zsh-david.plugin.zsh && source $HOME/.zshrc; echo "if you made changes please push to master with vu"' alias vd='vim $HOME/.zprezto-contrib/zsh-david/zsh-david.plugin.zsh' alias vu='cd $ZSH_CUSTOM/plugins/zsh-david; git commit -am "plugin update" && git push origin master; cd -' alias vi='vim' alias v='vim' alias vv='vim $HOME/.vimrc' alias vh="sudo vim /etc/hosts; echo hosts updated" alias s="ssh" alias m="mosh" alias serve="python2 -m SimpleHTTPServer" alias push="git push origin master" alias pull="git pull origin master" alias commit="git commit -a" 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 192.168.42.0/24" 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 cleardnscache="sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache; say DNS cache has been cleared" alias cleardnscache="sudo killall -HUP mDNSResponder; sudo dscacheutil -flushcache; say DNS cache has been cleared" #alias ls='ls --color=auto' #does not work on macos 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 # **** function definitions **** ## output handling log() { case $1 in "error") level="\033[31m✗\033[0m" ;; "warn") level="\033[33m!\033[0m" ;; "debug") level="\033[2md\033[0m" ;; "success") level="\033[32m✓\033[0m" ;; "info") level="i" ;; *) level="\033[31mLoglevel unknown. Programming error? ($1)\033[0m" ;; esac sleep 0.5; echo -e "[$level] ${@:2}" } # setup user accounts on linux systems # update them if existing # ? delete them # add authorized_keys setup_user() { if [ $1 ]; then log info "setting up account for $1" #TODO: do the groups exist beforehand? useradd -m -d /home/$1 -G "sudo sshusers docker" $1 if [ $? -ne 0 ]; then log error "error while creating user ($1)" fi else log error "no username given" return 1 fi } ## RDP client 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 } ## OS upgrade for various systems update() { 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 case $system in ubuntu|debian|raspbian) echo "Updating Ubuntu/Debian.." sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y ;; 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 } ## Thinkpad Trackpoint input fix (for for thinkpad x131e/chromebook) #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 #}