2014-03-14 17:04:46 -07:00
|
|
|
#!/bin/zsh
|
2013-06-28 05:22:14 -07:00
|
|
|
# for both zsh and bash
|
|
|
|
|
2014-11-12 20:36:15 -08:00
|
|
|
umask 022 # don't inherit last umask. pip will break itself.
|
2013-06-28 05:22:14 -07:00
|
|
|
|
2015-03-07 07:57:26 -08:00
|
|
|
hash -d e=/media/2tb/you
|
|
|
|
|
2013-07-01 02:22:36 -07:00
|
|
|
ADDPATH() {
|
|
|
|
grep ":$1:" <<<":$PATH:" >/dev/null || export PATH="$PATH:$1"
|
|
|
|
}
|
|
|
|
ADDPATH "$HOME/opt/local/bin"
|
2013-06-29 11:47:01 -07:00
|
|
|
|
2015-03-30 21:42:01 -07:00
|
|
|
# https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1380084
|
|
|
|
export SSH_AUTH_SOCK=0
|
|
|
|
|
2015-02-15 01:54:22 -08:00
|
|
|
r="$HOME/.gem/ruby/2.2.0/bin"
|
|
|
|
mkdir -p "$r" && ADDPATH "$r"
|
2014-06-02 06:54:57 -07:00
|
|
|
unset r
|
|
|
|
|
2015-05-06 14:22:04 -07:00
|
|
|
export GOPATH="$HOME/go"
|
|
|
|
ADDPATH "$GOPATH/bin"
|
|
|
|
|
2013-07-04 03:18:03 -07:00
|
|
|
ify() {
|
2014-06-02 06:54:57 -07:00
|
|
|
[ $# -ge 2 ] || return
|
|
|
|
local ex=$1
|
|
|
|
shift
|
|
|
|
$@ | $ex
|
2013-07-04 03:18:03 -07:00
|
|
|
}
|
|
|
|
|
2015-03-06 07:14:33 -08:00
|
|
|
has() { which "$1" >&/dev/null && which "$1"; }
|
2013-09-15 20:33:04 -07:00
|
|
|
|
2013-06-29 11:47:01 -07:00
|
|
|
# cleanup in case of inherited exports
|
|
|
|
for x in AR CC CPP CXX CFLAGS CPPFLAGS CXXFLAGS LDFLAGS RANLIB RC WINDRES; do
|
2013-11-11 15:11:22 -08:00
|
|
|
unset $x
|
2013-06-29 11:47:01 -07:00
|
|
|
done
|
2013-06-28 05:22:14 -07:00
|
|
|
|
2015-04-13 18:03:56 -07:00
|
|
|
[ "$LANG" != "en_US.UTF-8" ] && [ "$LANG" != "en_CA.UTF-8" ] && echo "Warning: LANG is $LANG"
|
2014-05-14 20:17:32 -07:00
|
|
|
|
2014-02-24 14:15:53 -08:00
|
|
|
# PuTTY over serial
|
|
|
|
[[ "$TERM" == vt102 ]] && export TERM="xterm"
|
|
|
|
|
2015-05-06 09:33:03 -07:00
|
|
|
# Qt is stupid and thinks we're running unity so it hides the menu bar
|
|
|
|
[[ "$DESKTOP_SESSION" == xfce ]] && export QT_QPA_PLATFORMTHEME=""
|
|
|
|
|
2013-06-28 05:22:14 -07:00
|
|
|
export PREFIX="$HOME/opt/local"
|
2015-06-07 18:03:25 -07:00
|
|
|
export CC="$(has clang || has clang-3.6 || has gcc)"
|
|
|
|
export CXX="$(has clang++ || has clang++-3.6 || has g++)"
|
2013-06-28 05:22:14 -07:00
|
|
|
export CFLAGS='-march=native -O2'
|
|
|
|
export LDFLAGS='-Wl,-O1,--sort-common,-z,relro'
|
|
|
|
export CFLAGS="$CFLAGS -I'$HOME/opt/local/include'"
|
|
|
|
export LDFLAGS="$LDFLAGS -L'$HOME/opt/local/lib'"
|
2013-12-22 15:00:43 -08:00
|
|
|
export CXXFLAGS="$CFLAGS"
|
2013-06-28 05:22:14 -07:00
|
|
|
export LD_LIBRARY_PATH= # -n isn't an option in zsh's export
|
2014-01-14 09:17:22 -08:00
|
|
|
export MAKEFLAGS="-j2"
|
2015-04-06 12:12:06 -07:00
|
|
|
export VST_SDK_DIR="$HOME/src/vstsdk2.4"
|
2015-05-06 13:33:39 -07:00
|
|
|
export LADSPA_PATH="/usr/lib/ladspa"
|
2013-06-28 05:22:14 -07:00
|
|
|
|
|
|
|
export EDITOR='vim -p'
|
|
|
|
|
|
|
|
# colors
|
|
|
|
for x in ls dir vdir grep fgrep egrep; do
|
|
|
|
alias $x="$x --color=auto"
|
|
|
|
done
|
2013-11-11 15:11:22 -08:00
|
|
|
#alias make="$(has colormake || has make)"
|
2013-06-28 05:22:14 -07:00
|
|
|
|
|
|
|
# just flags
|
|
|
|
export LESS='-SR'
|
2015-05-06 09:33:03 -07:00
|
|
|
alias db="dropbox_uploader"
|
2013-06-29 11:47:01 -07:00
|
|
|
alias makedbg='CFLAGS="-O0" LDFLAGS="-g" make'
|
2013-06-28 05:22:14 -07:00
|
|
|
alias fils="du -bad1"
|
|
|
|
alias lsa="ls -A --group-directories-first"
|
|
|
|
alias logs="logs -o cat -b -e"
|
2014-03-13 10:16:04 -07:00
|
|
|
alias logsf="logs -f -e"
|
2013-07-09 18:15:19 -07:00
|
|
|
alias diff="git diff --color=auto --no-ext-diff --no-index"
|
2015-05-06 09:33:03 -07:00
|
|
|
alias gs='git status' # rip ghostscript
|
|
|
|
alias gd='git diff -U2'
|
|
|
|
alias gds='git --no-pager diff --stat'
|
|
|
|
alias gl='git log --oneline'
|
2013-06-28 05:22:14 -07:00
|
|
|
|
|
|
|
# being specific
|
2015-05-20 20:34:03 -07:00
|
|
|
alias pip="sudo -H pip3"
|
2013-06-28 05:22:14 -07:00
|
|
|
alias irc="screen -dR irc irssi"
|
|
|
|
alias crawl='screen -dR crawl ssh crawl@crawl.develz.org -i ~/.ssh/crawl'
|
|
|
|
alias crawla='screen -dR crawl ssh crawl@crawl.akrasiac.org -l joshua -i ~/.ssh/crawl'
|
2015-02-15 01:54:22 -08:00
|
|
|
alias revend='objcopy -I binary -O binary --reverse-bytes=4'
|
2015-03-06 07:14:33 -08:00
|
|
|
alias aur="BUILDDIR=$HOME/src $HOME/sh/aur -jj"
|
2015-06-02 06:08:25 -07:00
|
|
|
alias clone='sudo rsync -aHA --info=progress2'
|
2013-06-28 05:22:14 -07:00
|
|
|
|
|
|
|
# providing extra functionality
|
|
|
|
# TODO: dotfiles first, like `LC_ALL=C ls -A` which doesnt work with -X flag
|
2013-07-04 03:18:03 -07:00
|
|
|
alias ll="ify less ls -ACX --group-directories-first --color=force"
|
2013-06-28 05:22:14 -07:00
|
|
|
alias counts='find . | wc -l'
|
|
|
|
alias exts='print -l *(:e:l) | sort | uniq -c | sort -n'
|
|
|
|
alias meow='( cd ~/play/meow; ~/sh/meow.sh/run -pa )'
|
|
|
|
alias nocom='grep -oP --line-buffered --color=never "^[^#]+"'
|
2015-05-06 14:22:04 -07:00
|
|
|
alias jrep='grep -aPo "[\x{20}-\x{7E}\x{4E00}-\x{9FFF}\x{3040}-\x{30FF}]+"'
|
|
|
|
alias bomb='uconv -f utf-8 -t utf-8 --add-signature'
|
2013-07-04 03:18:03 -07:00
|
|
|
alias unwrap='awk '\''BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$i;print "\n"}'\'
|
2013-07-04 02:56:57 -07:00
|
|
|
alias picky='{ pacman -Qgq base base-devel | tee -; pacman -Qtnq; } | sort | uniq -u'
|
2013-06-28 05:22:14 -07:00
|
|
|
alias unused='{ pacman -Qt; pacman -Qe | tee -; } | sort | uniq -u'
|
2014-03-14 16:57:06 -07:00
|
|
|
alias makepkgf='sudo -u $USER MAKEFLAGS=-j2 makepkg -Af --skipchecksums'
|
2014-06-02 06:54:57 -07:00
|
|
|
alias rakef='rake && gem build *.gemspec && gem install *.gem'
|
|
|
|
alias rot13='tr "A-Za-z0-9" "N-ZA-Mn-za-m5-90-4"'
|
|
|
|
alias cleanse='tr -cd "\11\12\15\40-\176"'
|
2015-04-06 12:12:06 -07:00
|
|
|
alias profile="CPUPROFILE=./a.pprof LD_PRELOAD=/usr/lib/libprofiler.so"
|
2015-05-04 16:52:07 -07:00
|
|
|
alias freq="cut -d' ' -f1 < ~/.histfile | sort | uniq -c | sort -rn | head"
|
2014-06-02 06:54:57 -07:00
|
|
|
|
|
|
|
function trash() {
|
|
|
|
dd status=none if=/dev/random bs=1 count="$1"
|
|
|
|
}
|
2013-06-28 05:22:14 -07:00
|
|
|
|
2015-06-10 21:32:14 -07:00
|
|
|
[ -e ~/sh/z/z.sh ] && . ~/sh/z/z.sh
|
2014-03-06 22:23:57 -08:00
|
|
|
|
2015-04-15 23:10:32 -07:00
|
|
|
# awful things
|
|
|
|
# i should really write a ladspa plugin that does this all at once and
|
|
|
|
# with attack/release smoothing so aliasing doesn't go through the roof!
|
|
|
|
_M_STEREO='aformat=channel_layouts=stereo'
|
|
|
|
_M_PRE_EMPH='equalizer=f=50.0:g=-10:width_type=o:w=4,equalizer=f=5000:g=+05:width_type=o:w=4'
|
|
|
|
_M_POST_EMPH='equalizer=f=50.0:g=+10:width_type=o:w=4,equalizer=f=5000:g=-05:width_type=o:w=4'
|
2015-05-06 13:33:39 -07:00
|
|
|
_M_COMPRESS='compand=0.001|0.001:0.25|0.25:-42/-42|0/-21:6:18:-30:0.001'
|
|
|
|
_M_LIMIT='compand=0.000|0.000:0.10|0.10:-9/-9|0/-6.:3:4.5:-9'
|
2015-05-20 20:34:03 -07:00
|
|
|
_M_KILL="$_M_STEREO,$_M_PRE_EMPH,$_M_COMPRESS,$_M_POST_EMPH"
|
2015-05-06 13:33:39 -07:00
|
|
|
|
|
|
|
crap_speakers='crap_eq_const_T420'
|
2015-06-07 18:03:25 -07:00
|
|
|
[ -e "/usr/lib/ladspa/${crap_speakers}.so" ] \
|
2015-12-03 05:52:31 -08:00
|
|
|
&& _M_SPEAKERS="ladspa=f=${crap_speakers}:p=$crap_speakers"
|
2015-04-13 22:29:12 -07:00
|
|
|
|
2015-03-30 21:42:01 -07:00
|
|
|
if [[ "$(uname -n)" != "banshee" ]]; then
|
2015-04-15 23:10:32 -07:00
|
|
|
MPV_STREAM_FLAGS="--quiet --no-sub --vo=opengl:swapinterval=0"
|
2015-04-13 18:03:56 -07:00
|
|
|
else
|
2015-12-03 05:52:31 -08:00
|
|
|
MPV_STREAM_FLAGS="--quiet --no-sub --af=lavfi=[$_M_KILL,$_M_SPEAKERS,$_M_LIMIT]"
|
2015-03-30 21:42:01 -07:00
|
|
|
fi
|
2014-03-06 22:23:57 -08:00
|
|
|
|
2015-04-13 22:29:12 -07:00
|
|
|
LIVESTREAMER_FLAGS=""
|
|
|
|
|
2014-03-06 22:23:57 -08:00
|
|
|
twitch(){
|
2015-11-24 19:01:34 -08:00
|
|
|
local stream="$1"
|
|
|
|
shift
|
|
|
|
# TODO: fix all the shit
|
|
|
|
livestreamer "twitch.tv/$stream" best "$@" -p mpv $LIVESTREAMER_FLAGS -a \
|
2014-03-06 22:23:57 -08:00
|
|
|
"$MPV_STREAM_FLAGS ${2:+--autofit=}${2:-} {filename}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# hitbox uses rtmp but mpv doesnt support rtmp dump parameters
|
|
|
|
hitbox(){
|
2015-11-24 19:01:34 -08:00
|
|
|
local stream="$1"
|
|
|
|
shift
|
|
|
|
livestreamer "hitbox.tv/$stream" best "$@" -p mpv $LIVESTREAMER_FLAGS -a \
|
2014-03-06 22:23:57 -08:00
|
|
|
"$MPV_STREAM_FLAGS ${2:+--autofit=}${2:-} {filename}"
|
|
|
|
}
|