if [ "$TERM" = "xterm-termite" ] ; then #Termite is in colors, but it doesn't like to tell anyone export TERM="xterm-256color" fi echo -ne '[ ]\r' export HISTFILE=$HOME/.zsh_history for config (~/.zsh/*.zsh) source $config ZSH_THEME="af-magic" source "$HOME/.antigen/antigen.zsh" setopt APPEND_HISTORY HIST_STAMPS="dd.mm.yyyy" HISTSIZE=12000 SAVEHIST=10000000 setopt INTERACTIVECOMMENTS setopt EXTENDED_GLOB setopt HIST_EXPIRE_DUPS_FIRST setopt EXTENDED_HISTORY setopt APPEND_HISTORY SHARE_HISTORY HISTIGNOREALLDUPS if [ -f /etc/zsh_command_not_found ] ; then source /etc/zsh_command_not_found fi export DISABLE_AUTO_TITLE=true export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$(readlink -e ~/bin)" export EDITOR='vim' # For pasting in commands that start with $ $ () { $* } st () { command="${@: -1}" while (( $# > 1 )); do if [[ "$command" == "r" ]]; then echo "Restarting $1" sudo service "$1" restart elif [[ "$command" == "s" ]]; then echo "Starting $1" sudo service "$1" start elif [[ "$command" == "x" ]]; then echo "Stopping $1" sudo service "$1" stop elif [[ "$command" == "i" ]]; then echo "Status of $1" service "$1" status fi shift done } asroot(){ # Use temporary file for added security TEMPFILE=$(tempfile) xauth extract $TEMPFILE $DISPLAY sudo zsh -c "xauth merge $TEMPFILE;(srm $TEMPFILE||rm $TEMPFILE)&'$@';" } dsl() { while (( $# > 0 )); do readlink $1 2>&1 >/dev/null && mv $(readlink $1) $1 shift done } dedir(){ mv "$1"/* . rmdir "$1" if (( !? != 0 )); then mv "$1"/.* . fi rmdir "$1" } alias cpatch='diff -crB' alias capatch='patch --dry-run -p1 -i' alias apatch='patch -p1 -i' alias pg="pcregrep -M" alias eix="eix -F" alias mouse1="xmodmap <(echo pointer = 1 2 3)" alias mouse2="xmodmap <(echo pointer = 3 2 1)" alias where="readlink -e" alias ocp="ocp -vs0 -dcurses" alias dumpx="xauth extract /tmp/xauthstuff $DISPLAY" alias impx="xauth merge /tmp/xauthstuff;rm /tmp/xauthstuff" alias sudo='sudo ' alias con='git x php app/console' alias srm='srm -dv' alias disphost='export DISPLAY=:0.0' alias ll='ls -AlhF' alias la='ls -A' alias l='ls -CF' alias logout='sudo pkill -u $USER' rsh(){ if [ -z $1 ] ; then echo "Valid hostnames:" cat /home/stonewareslord/syncthing/shared/ips return 1 fi ADDR=$(cat /home/stonewareslord/syncthing/shared/ips | sed -rne "s/^$1: //pi") shift if [ -z $ADDR ] ; then echo "Hostname not found" return 2 fi echo "SSH to $ADDR..." tsh $ADDR $* } fixsh(){ sed -i -e $1"d" ~/.ssh/known_hosts } alias tmux='tmux -2' alias less='less -R' alias tree='tree -C' alias skim="(head -5; tail -5) <" alias cp='rsync --partial -ha --info=progress2 "$@"' mv() { /bin/mv -v "$@" } m() { mv "$@" } compdef _cp c cfat m mv cp copy alias dt='date "+%F %T"' alias awake='disphost; while true; do xdotool mousemove 0 0; sleep 60; done' alias adk='/home/stonewareslord/Applications/adk/bin/studio.sh & disown' alias resource='. ~/.zshrc' alias etup='sudo etc-update' alias search='apt-cache search' if [ "$(uname)" != "Darwin" ]; then # Not Mac alias ls='ls --color=always -F' alias steamo='sudo kill -9 `pidof steam`;sudo unshare -n -- sh -c "ifconfig lo up;sudo -u stonewareslord steam" > /dev/null 2>&1 & disown' alias matlab='matlab -glnx86' alias bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state|to\ full|percentage"' if command -v greadlink 2>&1 >/dev/null; then alias readlink='greadlink' fi fi if test -f /etc/gentoo-release; then # Gentoo ins(){ echo "args: $*" # Beep, verbose, ask sudo zsh -c "emerge --autounmask-write -Ava $*" echo "\a" } # For emerging with absolute paths em(){ # Beep, verbose, ask EMERGE_ARGS="-Ava" X="" for var in "$@" do if [[ "$var" =~ ^- ]]; then EMERGE_ARGS="$EMERGE_ARGS $var" else X="$X =$var" fi done echo sudo emerge "$EMERGE_ARGS""$X" sudo emerge "$EMERGE_ARGS""$X" echo "\a" } update(){ # If this is a server computer if [ "$(hostname|cut -b1)" = "S" ] ; then echo "You're a server. Exiting" return fi cd /usr/portage >/dev/null sudo zsh -c "git up&&echo Done pulling&&eix-update&&echo Done with eix" cd ->/dev/null echo '\a' } alias upgrade='sudo emerge --update --newuse --with-bdeps=y --deep --verbose --tree --keep-going=y --verbose-conflicts --alert --ask @world;echo \\a' elif test -f /etc/lsb-release; then # Ubuntu alias install='sudo apt-get --show-progress install' alias remove='sudo apt-get --show-progress remove' alias update='sudo apt-get update' alias upgrade='sudo apt-get --show-progress upgrade' alias autoremove='sudo apt-get --show-progress autoremove' alias updateall='sudo sh -c "apt-get update;apt-get upgrade -y;apt-get dist-upgrade -y;apt-get autoremove -y"' fi alias ..='k ..' alias ...='k ../..' alias ....='k ../../..' alias .....='k ../../../..' alias ......='k ../../../../..' alias .......='k ../../../../../..' alias ........='k ../../../../../../..' alias .........='k ../../../../../../../..' alias ..........='k ../../../../../../../../..' alias ...........='k ../../../../../../../../../..' alias ............='k ../../../../../../../../../../..' alias .............='k ../../../../../../../../../../../..' alias ..............='k ../../../../../../../../../../../../..' alias ...............='k ../../../../../../../../../../../../../..' alias ytdl="youtube-dl $@ -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'" alias tux="wemux" alias rmgit="git remote rm origin;git remote rm https;git remote rm oOrigin;git remote rm oHttps" alias rname="while true;do echo -n \"Rename: \";read A;echo -n \"To: \";read B;i3-msg 'rename workspace $A to $B';done" alias g="git $@" alias stdns="sudo sh -c 'echo nameserver 8.8.8.8 > /etc/resolv.conf'" alias fvim="vim -u NONE +\"so ~/.vim/plugged/flappyvird-vim/plugin/flappyvird.vim\" +\"so ~/.vim/plugged/flappyvird-vim/autoload/flappyvird.vim\" +\":FlappyVird\" +\":q\"" alias fk='k `fzf --no-mouse -m -1 -x`' alias fkill='ps -ef | sed 1d | fzf --no-mouse -m -1 -x | awk "{print $2}" | xargs kill -${1:-9}' alias susp="sudo true&&(slock&echo mem | sudo tee /sys/power/state >/dev/null)" alias aoeu='setxkbmap -layout us -option "' alias asdf='setxkbmap -layout dvorak -option ""' alias -s html="firefox" alias -s log="less -MN" alias -s odt="libreoffice" alias -s doc="libreoffice" alias -s docx="libreoffice" alias -g PASTE='2>&1 |curl --data-urlencode text@- https://austenwares.com/paste/api/create' alias -g c='rsync --partial -ha --info=progress2 "$@"' alias -g cfat='rsync --partial -hrlc --info=progress2 "$@"' alias -g F='`fzf --no-mouse -m -1 -x`' alias -g nify=" > /dev/null 2>&1 &" alias -g nifyd=" > /dev/null 2>&1 & disown" alias -g L="2>&1|less" #alias -g L="2>&1|vimpager" alias -g G='|& ag' export FZF_COMPLETION_OPTS='--no-mouse -m -1 -x' bp(){ echo '\a' } apush(){ adb push $* & pv -d $! } ltar(){ tar -cf - $@|pv -WcN tar|xz|pv -WcN lzma #tar -cf - $@|pv -WcN tar -s $(echo $(du -sb $@|awk '{print $1}'|tr '\n' '+')0|bc)|gzip|pv -WcN dest #tar -cf - $@|pv -WcN tar -s $(echo $(du -sb $@|awk '{print $1}'|tr '\n' '+')0|bc)|gzip|pv -WcN dest } ctar(){ tar -cf - $@|pv -WcN tar|gzip|pv -WcN gzip } offline(){ if [ ! -z "$@" ] ; then sudo unshare -n -- sudo -u stonewareslord zsh -c "$@" else sudo unshare -n -- sudo -u stonewareslord LP_MARK_PREFIX=" $(tput setaf 1)(offline)$(tput sgr0) " zsh fi } smon(){ timeout 1s pdsh -R ssh -w 10.0.1.196,10.0.1.207 "$@" } dnstest(){ echo "resolv.conf:" cat /etc/resolv.conf echo "Testing DNS:" dig google.com echo "Testing ping:" ping -c 2 8.8.8.8 echo "Testing IP curl:" curl -k http://98.26.78.121/b/ echo echo "Testing DNS" curl ifconfig.me } cinitify(){ mkdir $2 cd $2 git init git remote add origin git@austenwares.com:$1/$2.git git remote add https https://austenwares.com/gitlab/$1/$2.git #Offline mode git remote add oOrigin git@10.0.1.200:$1/$2.git git remote add oHttps https://10.0.1.200/gitlab/$1/$2.git git remote -v git config http.sslVerify false if [[ $3 == "-v" ]] ; then # Vagrant repository vagrant init $4 echo ".vagrant" > .gitignore git add . git commit -m "Initial commit" vagrant up elif [[ ! $3 == "-r" ]] ; then echo -n "Pull from: " read from git pull $from git checkout master fi } initify(){ git init git remote add origin git@austenwares.com:$1/$2.git git remote add https https://austenwares.com/gitlab/$1/$2.git #Offline mode git remote add oOrigin git@10.0.1.200:$1/$2.git git remote add oHttps https://10.0.1.200/gitlab/$1/$2.git git remote -v git config http.sslVerify false if [[ ! $3 == "-r" ]] ; then echo -n "Pull from: " read from git pull $from git checkout master fi } tsh(){ ssh -X $* if which ponysay >/dev/null; then ponysay "Connection closed!" else echo "\n\n\n\n\n\n\n\n\n\nSESSION CLOSED\n\n\n\n\n\n\n\n\n\n" fi } mcl(){ mkdir -p $1 cd $1 } create-repo(){ PRIVATE="true" while getopts ":p" opt; do case $opt in p) echo "-p was used, making public" PRIVATE="false" shift ;; \?) echo "Usage: create-repo [-p] name" >&2 return 1 ;; esac done if [ -z "$1" ]; then echo "No repo name" >&2 return 2 fi echo -n "Username: " read username echo -n "Password: " read -s password curl --user "$username:$password" -d name="$1" -d private="$PRIVATE" https://austenwares.com/gogs/api/v1/user/repos } rc(){ case $1 in z) vim ~/.zshrc;; v) vim ~/.vimrc;; i) vim ~/.i3/config;; use) sudo vim /etc/portage/package.use/package.use;; make) sudo vim /etc/portage/make.conf;; unmask) sudo vim /etc/portage/package.unmask/package.unmask;; mask) sudo vim /etc/portage/package.mask/package.mask;; accept_keywords) sudo vim /etc/portage/package.accept_keywords/package.accept_keywords;; license) sudo vim /etc/portage/package.license/package.license;; *) echo "Opts:\nz v i\nuse make unmask mask accept_keywords license" esac } pub-git-init(){ # Get the project name branch=$(git remote -v | ag '^origin\s+' | sed -e 's/^origin\s*//' | cut -d\ -f1 | sed -r -e 's/^.+\///' -e 's/#.+$//' -e 's/\.git$//' | head -n1) echo "Branch: $branch" # Get the hashed project name enc_branch=$(echo "$branch" | sha512sum | cut -d\ -f1) git remote add local "gcrypt::git@localhost:stonewareslord/79a79b1a6e37813d9226872c6428aca29eec9f6111558109861cb0dcd2f0ffc8198deea4e361f84e170989212452fdfb21e0ef690da2ad399c03ce308d79dcfe#$enc_branch" git remote add ncsu "gcrypt::git@github.ncsu.edu:agadler/a86a0f8757772be2ec617b395a0716679bfce51c1bfdeb8da6127feebd84facde645e9e30188318344eb458f5834e3d86800.git#$enc_branch" git remote add gitlab "gcrypt::git@gitlab.com:stonewareslord/e6e03ea006d55de0970a28bcb7fcf65f4c66f98f50830bd69b50c5dc502bdf1a4e4172187cfb5fcef8c32bd7fb316bdc67d7d86713ebfe232f97eb303ac316ae.git#$enc_branch" git remote add aws "gcrypt::git@aws:stonewareslord/5e0701d5b5b2118127d378c084be9a1dfb33d185d3e2c5da30a3984f5118e3d5136f3f3b038462bccd538e93f9e32cb06136.git#$enc_branch" git config remote.ncsu.gcrypt-participants "CCDFE3F1" git config remote.gitlab.gcrypt-participants "CCDFE3F1" } pub-git-rm(){ if (( $# == 0 )) ; then git remote rm local git remote rm ncsu git remote rm gitlab git remote rm aws fi while (( $# > 0 )) ; do git remote rm "$1" shift done } pub-git-push(){ if (( $# == 0 )) ; then git push local --all && git push local --tags git push ncsu --all && git push ncsu --tags git push gitlab --all && git push gitlab --tags git push aws --all && git push aws --tags fi while (( $# > 0 )) ; do git push "$1" --all && git push "$1" --tags shift done } pub-git-clone(){ case $1 in ncsu) remote="gcrypt::git@github.ncsu.edu:agadler/a86a0f8757772be2ec617b395a0716679bfce51c1bfdeb8da6127feebd84facde645e9e30188318344eb458f5834e3d86800.git#" ;; gitlab) remote="gcrypt::git@gitlab.com:stonewareslord/e6e03ea006d55de0970a28bcb7fcf65f4c66f98f50830bd69b50c5dc502bdf1a4e4172187cfb5fcef8c32bd7fb316bdc67d7d86713ebfe232f97eb303ac316ae.git#" ;; local) remote="gcrypt::git@localhost:stonewareslord/79a79b1a6e37813d9226872c6428aca29eec9f6111558109861cb0dcd2f0ffc8198deea4e361f84e170989212452fdfb21e0ef690da2ad399c03ce308d79dcfe#" ;; aws) remote="gcrypt::git@aws:stonewareslord/5e0701d5b5b2118127d378c084be9a1dfb33d185d3e2c5da30a3984f5118e3d5136f3f3b038462bccd538e93f9e32cb06136.git#" ;; *) echo "Opts: local ncsu gitlab" ; return 1 esac shift if [ -z "$1" ] ; then echo "No arg2" return 2 fi branch=$(echo $1 | sha512sum | cut -d\ -f1) git clone "$remote$branch" $1 } k(){ #More than 1 arguement if [[ $# > 1 ]] ; then vim $@ elif [ -d "$@" ] ; then #cd then ls cd "$@" && ls elif [[ "$@" == "-" ]] ; then #Because if this isn't here, k - won't work cd - && ls elif [ -f "$@" ] ; then #Extract if it's extractable case $1 in *.tar.xz) pv $1|tar -xJf - ;; *.tar.bz2) pv $1|tar -xjf - ;; *.tar.gz) pv $1|tar -xzf - ;; *.tar) pv $1|tar -xf - ;; *.tbz2) pv $1|tar -xjf - ;; *.tgz) pv $1|tar -xzf - ;; *.lzma) pv $1|tar --lzma -xf - ;; *.xz) pv $1|tar -xJf - ;; *.bz2) bunzip2 $1 ;; *.rar) rar x $1 ;; *.gz) gunzip $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *.lrz) lrzuntar $1 ;; *) vim $1 esac else #Edit with vim echo -n "vim? " read a vim "$@" fi } #source ~/.zsh/*.zsh # To resize, # :%S/\[([# ]{9})\]/[\1 ] ####echo -ne '[# ]\r' ####antigen bundle Schnouki/git-annex-zsh-completion ###echo -ne '[## ]\r' ###antigen bundle stonewareslord/omg ###echo -ne '[### ]\r' ###antigen theme stonewareslord/oh-my-git-themes af-magic ###echo -ne '[#### ]\r' ###antigen bundle stonewareslord/lpr ####echo -ne '[##### ]\r' ####antigen bundle zsh-users/zsh-completions src ####echo -ne '[###### ]\r' ####antigen bundle sharat87/autoenv ###echo -ne '[####### ]\r' ###antigen bundle zsh-users/zsh-syntax-highlighting ###echo -ne '[######## ]\r' ###antigen apply ###echo -ne '[#########]\r' echo -ne '[# ]\r' antigen bundle stonewareslord/omg echo -ne '[## ]\r' antigen theme stonewareslord/oh-my-git-themes af-magic echo -ne '[### ]\r' antigen bundle stonewareslord/lpr echo -ne '[#### ]\r' antigen bundle zsh-users/zsh-syntax-highlighting echo -ne '[##### ]\r' antigen apply echo -ne '[######]\r' echo # OPAM configuration . /home/stonewareslord/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || true (( $+TMUX )) && unset zle_bracketed_paste [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh