1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 04:29:03 -08:00
rc/home/-shrc

154 lines
5.2 KiB
Bash

#!/bin/zsh
# for both zsh and bash
#umask 027 # screw others
umask 022 # don't inherit last umask. pip will break itself.
hash -d e=/media/2tb/you
ADDPATH() {
grep ":$1:" <<<":$PATH:" >/dev/null || export PATH="$PATH:$1"
}
ADDPATH "$HOME/opt/local/bin"
# https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1380084
export SSH_AUTH_SOCK=0
r="$HOME/.gem/ruby/2.2.0/bin"
mkdir -p "$r" && ADDPATH "$r"
unset r
export GOPATH="$HOME/go"
ADDPATH "$GOPATH/bin"
ify() {
[ $# -ge 2 ] || return
local ex=$1
shift
$@ | $ex
}
has() { which "$1" >&/dev/null && which "$1"; }
# cleanup in case of inherited exports
for x in AR CC CPP CXX CFLAGS CPPFLAGS CXXFLAGS LDFLAGS RANLIB RC WINDRES; do
unset $x
done
[ "$LANG" != "en_US.UTF-8" ] && [ "$LANG" != "en_CA.UTF-8" ] && echo "Warning: LANG is $LANG"
# PuTTY over serial
[[ "$TERM" == vt102 ]] && export TERM="xterm"
# Qt is stupid and thinks we're running unity so it hides the menu bar
[[ "$DESKTOP_SESSION" == xfce ]] && export QT_QPA_PLATFORMTHEME=""
export PREFIX="$HOME/opt/local"
export CC="$(has clang || has clang-3.6 || has gcc)"
export CXX="$(has clang++ || has clang++-3.6 || has g++)"
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'"
export CXXFLAGS="$CFLAGS"
export LD_LIBRARY_PATH= # -n isn't an option in zsh's export
export MAKEFLAGS="-j2"
export VST_SDK_DIR="$HOME/src/vstsdk2.4"
export LADSPA_PATH="/usr/lib/ladspa"
export EDITOR='vim -p'
# colors
for x in ls dir vdir grep fgrep egrep; do
alias $x="$x --color=auto"
done
#alias make="$(has colormake || has make)"
# just flags
export LESS='-SR'
alias db="dropbox_uploader"
alias makedbg='CFLAGS="-O0" LDFLAGS="-g" make'
alias fils="du -bad1"
alias lsa="ls -A --group-directories-first"
alias logs="logs -o cat -b -e"
alias logsf="logs -f -e"
alias diff="git diff --color=auto --no-ext-diff --no-index"
alias gs='git status' # rip ghostscript
alias gd='git diff -U2'
alias gds='git --no-pager diff --stat'
alias gl='git log --oneline'
# being specific
alias erc="e ~/.zshrc ~/shrc.zsh ~/.bashrc ~/.vimrc"
alias pip="sudo -H pip3"
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'
alias revend='objcopy -I binary -O binary --reverse-bytes=4'
alias fucksystemd='dmesg | grep -v audit'
alias aur="BUILDDIR=$HOME/src $HOME/sh/aur -jj"
alias clone='sudo rsync -aHA --info=progress2'
alias wraith="ssh -i ~/.ssh/id_rsa_email root@159.203.4.16"
# providing extra functionality
# TODO: dotfiles first, like `LC_ALL=C ls -A` which doesnt work with -X flag
alias ll="ify less ls -ACX --group-directories-first --color=force"
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 "^[^#]+"'
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'
alias unwrap='awk '\''BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$i;print "\n"}'\'
alias picky='{ pacman -Qgq base base-devel | tee -; pacman -Qtnq; } | sort | uniq -u'
alias unused='{ pacman -Qt; pacman -Qe | tee -; } | sort | uniq -u'
alias makepkgf='sudo -u $USER MAKEFLAGS=-j2 makepkg -Af --skipchecksums'
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"'
alias profile="CPUPROFILE=./a.pprof LD_PRELOAD=/usr/lib/libprofiler.so"
alias freq="cut -d' ' -f1 < ~/.histfile | sort | uniq -c | sort -rn | head"
function trash() {
dd status=none if=/dev/random bs=1 count="$1"
}
[ -e ~/sh/z/z.sh ] && . ~/sh/z/z.sh
# 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'
_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'
_M_KILL="$_M_STEREO,$_M_PRE_EMPH,$_M_COMPRESS,$_M_POST_EMPH"
crap_speakers='crap_eq_const_T420'
[ -e "/usr/lib/ladspa/${crap_speakers}.so" ] \
&& _M_SPEAKERS="ladspa=file=${crap_speakers}.so:label=$crap_speakers"
if [[ "$(uname -n)" != "banshee" ]]; then
MPV_STREAM_FLAGS="--quiet --no-sub --vo=opengl:swapinterval=0"
else
MPV_STREAM_FLAGS="--quiet --no-sub --af=lavfi=[$_M_KILL],$_M_SPEAKERS,lavfi=[$_M_LIMIT]"
fi
LIVESTREAMER_FLAGS=""
twitch(){
local stream="$1"
shift
# TODO: fix all the shit
livestreamer "twitch.tv/$stream" best "$@" -p mpv $LIVESTREAMER_FLAGS -a \
"$MPV_STREAM_FLAGS ${2:+--autofit=}${2:-} {filename}"
}
# hitbox uses rtmp but mpv doesnt support rtmp dump parameters
hitbox(){
local stream="$1"
shift
livestreamer "hitbox.tv/$stream" best "$@" -p mpv $LIVESTREAMER_FLAGS -a \
"$MPV_STREAM_FLAGS ${2:+--autofit=}${2:-} {filename}"
}