# make aliases and other stuff work in sudo
alias sudo='sudo '

# always use nvim, see exports
alias vim=$EDITOR
alias vi=$EDITOR
alias v=$EDITOR
alias vimdiff='$EDITOR -d'
alias vdiff='$EDITOR -d'
alias vd='$EDITOR -d'

# Easier navigation: .., ..., ~ and -
alias ~="cd ~"
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias q='exit'

# suffix-aliases for file-types (zsh only)
alias -s css=$EDITOR
alias -s scss=$EDITOR
alias -s js=$EDITOR
alias -s html=$EDITOR
alias -s md=$EDITOR
alias -s txt=$EDITOR

# clipper -- https://github.com/wincent/clipper
alias clip="nc localhost 8377"

# better ls / l command
alias l='ls -alGp'

# mutt
alias m='neomutt'
# alias for syncing everything
alias O="cd ~ && mbsync -a && mu index && vdirsyncer sync"

# Gitty gitgit
alias g="git"
alias gf="git-flow"
alias gs="git status"
alias ggpl='git pull origin $(current_branch)'
alias ggps='git push origin $(current_branch)'
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
alias gsmu='git submodule init && git submodule update'
alias gsmuu='git submodule foreach git pull origin master'
alias gmo='$EDITOR $(git ls-files -m)'

# tmux
alias t='tmux -u -2'
alias ta='tmux -u attach'

# all in one homebrew, gem update commands
alias brewup='brew update && brew upgrade && brew cu -a -f -y && brew cleanup'
alias upall='brewup && npm-check -gu'

# temp fix for dnsmasq-bootup/unifi-java fuckup
# <key>JVMRuntime</key> <string>adoptopenjdk-8.jdk</string>
alias dnsmasqfix='sudo brew services stop dnsmasq && sudo mkdir /usr/local/etc/dnsmasq.d && sudo brew services start dnsmasq'
alias unififix='sudo ln -s /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk /Applications/UniFi.app/Contents/PlugIns/adoptopenjdk-8.jdk && sudo v /Applications/UniFi.app/Contents/Info.plist'

# other often used stuff, mostly node/npm
alias ns="npm start"
alias nb="npm run build"
alias npmre='rm -f package-lock.json && rm -rf node_modules && npm install'
alias ys='yarn develop'
alias yp='yarn lint && yarn production'
alias yre='rm -f yarn.lock && rm -rf node_modules && yarn'

# often used folder shortcuts
alias web='cd ~/Sites && l'
alias rep='cd ~/Repositories && l'
alias dot='cd ~/Dotfiles && l'

# random usefull stuff
alias dnsflush='sudo dscacheutil -flushcache'
alias lock="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

# imagemagick downsampling shortcuts (c&p retina folder, run, done!)
alias jpg25='mogrify -format jpg -resize 25% -strip -quality 80 *.jpg'
alias jpg50='mogrify -format jpg -resize 50% -strip -quality 80 *.jpg'
alias png25='mogrify -format png -resize 25% -strip -quality 80 *.png'
alias png50='mogrify -format png -resize 50% -strip -quality 80 *.png'
alias webimg='mogrify -format jpg -resize 1600x1600 -strip -quality 70'
alias anigif='convert -delay 12 -loop 0 *.jpg animated.gif'
