#!/bin/zsh # for both zsh and bash umask 022 # don't inherit last umask. pip will break itself. [ -z "$MSYSTEM" ] && cdrive="/cygdrive/c" || cdrive="/c" [ -z "$MSYSTEM" ] && ddrive="/cygdrive/d" || ddrive="/d" hash -d c="$cdrive" hash -d d="$ddrive" hash -d cyg=~c"/cygwin/home/$USER" hash -d msys=~c"/msys64/home/$USER" hash -d e="/media/chibi" hash -d win=~c"/Users/$USER" hash -d mm=~c"/Program Files (x86)/mupen64plus/mm" hash -d py=~win"/Dropbox/py" ADDPATH() { new="$(readlink -f "$1")" [ -d "$new" ] || echo -E "ADDPATH: path doesn't exist: $new" >&2 grep ":$new:" <<<":$PATH:" >/dev/null || export PATH="$PATH:$new" } ADDPATH "$HOME/opt/local/bin" [ -n "$MSYSTEM" ] && ADDPATH "/c/path" # https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1380084 export SSH_AUTH_SOCK=0 # https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-save-thousands-of-system-calls/ # i haven't checked if this makes any difference personally, but may as well, eh? export TZ=':/etc/localtime' # damnit python. export PYTHONIOENCODING=utf-8 ify() { [ $# -ge 2 ] || return local ex=$1 shift $@ | $ex } has() { which "$1" >&/dev/null && which "$1"; } # cleanup in case of inherited exports unset PREFIX CC CPP CXX LD CFLAGS CPPFLAGS CXXFLAGS LDFLAGS unset AR RANLIB RC WINDRES OBJDUMP OBJCOPY COMPILER_PATH unset LD_LIBRARY_PATH if [ "$LANG" != "en_US.UTF-8" ] && [ "$LANG" != "en_CA.UTF-8" ]; then if [ -z "$MSYSTEM" ] || [ "$LANG" != "C.UTF-8" ]; then echo -E "Warning: LANG is $LANG" >&2 fi fi # 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 EDITOR='vim' export CC="$(has clang || has gcc)" export CXX="$(has clang++ || has g++)" export CXXFLAGS="$CFLAGS" export MAKEFLAGS="-j2" export OMP_NUM_THREADS=4 export VST_SDK_DIR="$HOME/src/vstsdk2.4" export LADSPA_PATH="/usr/lib/ladspa" export NQDIR="$HOME/play" # enable colors for x in ls dir vdir grep fgrep egrep; do alias $x="$x --color=auto" done unset x alias lr="lr -G" #alias make="$(has colormake || has make)" # just flags export LESS='-SRQ' alias db="dropbox_uploader" alias fils="du -bahd1" 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' alias perlu='perl -Mopen=locale -Mutf8' alias rgn="rg --no-ignore" whoa=( -Wall -Wextra # -Winline # only for C # -Wshadow # only for C -Wwrite-strings # -Wmissing-prototypes -Werror=implicit-function-declaration -Werror=uninitialized -Werror=format-security -Werror=format-extra-args -Werror=pointer-to-int-cast -Werror=int-to-pointer-cast -Werror=return-type -Werror=memset-transposed-args # -Werror=tautological-constant-out-of-range-compare # gcc doesn't like this # -Werror=undef -Wno-unused -Wno-padded -Wno-missing-field-initializers # -Wno-type-limits # bad for generated code (macros, templates) -Wno-misleading-indentation # gcc 6 -Wno-disabled-macro-expansion # clang -Wno-language-extension-token # clang -Wno-unknown-warning-option # clang # trying some stuff: -Wduplicated-cond # gcc 6 -Wduplicated-branches # gcc 7 -Wlogical-op -Wrestrict # gcc 7 -Wnull-dereference # gcc 6 #-Wjump-misses-init # only for C -Wdouble-promotion -Wformat=2 ) welp=( -fno-exceptions -fno-non-call-exceptions -fno-rtti #-fno-use-cxa-atexit #-ffreestanding -fno-common -ffunction-sections -fdata-sections -Wl,--gc-sections -finline-small-functions -findirect-inlining ) # being specific [ -e "$HOME/python3" ] && alias py="~/python3" || alias py="python3" alias pip="sudo -H pip3" alias irc='screeny "$USER" irc irssi' alias crawl='screeny "$USER" crawl ssh crawl@crawl.develz.org -i ~/.ssh/crawl' alias crawla='screeny "$USER" crawl ssh joshua@crawl.akrasiac.org -i ~/.ssh/crawl' alias revend='objcopy -I binary -O binary --reverse-bytes=4' alias aur="BUILDDIR=$HOME/src $HOME/sh/aur -jj" alias clone='sudo rsync -aHA --info=progress2 --no-i-r' alias meow='( cd ~/play/meow; ~/sh/meow.sh/run -pa )' alias get="git clone --single-branch --depth 1" alias aligntabs="column -t -s$'\t'" alias gc="git column --mode=dense --padding=2" alias pippy="py -m pip install --upgrade --upgrade-strategy only-if-needed" ll() { { lr -1lshGG -o tev -t 'name~~".*"||type==d' "$@" \ && lr -1lshGG -o tev -t 'name!~~".*"&&type!=d' "$@" \ || ls -lAX --group-directories-first --color=force "$@"; } | less } # providing extra functionality alias counts='find . | wc -l' alias exts='print -l *(:e:l) | sort | uniq -c | sort -n' alias freq="cut -d' ' -f1 < ~/.histfile | sort | uniq -c | sort -rn | head" # alias nocom='egrep -v --line-buffered --color=never "^[[:space:]]*(//|#)"' 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 cleanse='tr -cd "\11\12\15\40-\176"' alias rot13='tr "A-Za-z0-9" "N-ZA-Mn-za-m5-90-4"' alias unwrap='awk '\''BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$i;print "\n"}'\' alias double='awk "{print;print}"' alias join2='paste -d" " - -' alias katagana='perlu -MUnicode::Normalize -pe'"'"'$_=NFKD($_)=~y/ァ-ヶ /ぁ-ゖ /r'"'" # alias picky='{ pacman -Qgq base base-devel xorg xorg-drivers xfce4 | double; pacman -Qeq; } | sort | uniq -u' alias unused='{ pacman -Qtq; pacman -Qeq | double; } | sort | uniq -u' # alias makepkgf='sudo -u $USER makepkg -Af --skipchecksums --skippgpcheck' alias rakef='rake && gem build *.gemspec && gem install *.gem' trash() { dd status=none if=/dev/random bs=1 count="$1" } unset cdrive unset ddrive . ~/.streamcrap . ~/.ea