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

209 lines
6.2 KiB
Text
Raw Normal View History

2014-03-14 17:04:46 -07:00
#!/bin/zsh
2013-06-28 05:22:14 -07:00
# for both zsh and bash
2019-05-27 03:10:54 -07:00
# umask should be reset else pip might make faulty installations.
umask 022
2013-06-28 05:22:14 -07:00
2016-10-24 00:41:37 -07:00
[ -z "$MSYSTEM" ] && cdrive="/cygdrive/c" || cdrive="/c"
2018-08-03 20:45:30 -07:00
[ -z "$MSYSTEM" ] && ddrive="/cygdrive/d" || ddrive="/d"
2016-10-24 00:41:37 -07:00
hash -d c="$cdrive"
2018-08-03 20:45:30 -07:00
hash -d d="$ddrive"
2018-02-21 01:43:05 -08:00
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"
2015-03-07 07:57:26 -08:00
2013-07-01 02:22:36 -07:00
ADDPATH() {
2015-12-13 10:22:18 -08:00
new="$(readlink -f "$1")"
2019-05-27 03:08:54 -07:00
[ -d "$new" ] || echo -E "ADDPATH: path doesn't exist: $new" >&2
2015-12-13 10:22:18 -08:00
grep ":$new:" <<<":$PATH:" >/dev/null || export PATH="$PATH:$new"
2013-07-01 02:22:36 -07:00
}
ADDPATH "$HOME/opt/local/bin"
2016-10-25 20:50:20 -07:00
[ -n "$MSYSTEM" ] && ADDPATH "/c/path"
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
2017-02-24 15:23:26 -08:00
# 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'
2017-04-06 06:30:51 -07:00
# damnit python.
export PYTHONIOENCODING=utf-8
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
}
2016-12-15 23:39:52 -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
2016-12-09 17:19:28 -08:00
unset PREFIX CC CPP CXX LD CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
2019-05-30 01:25:49 -07:00
unset AR RANLIB RC WINDRES OBJDUMP OBJCOPY
2017-01-30 13:59:28 -08:00
unset LD_LIBRARY_PATH
2013-06-28 05:22:14 -07:00
2019-05-27 02:49:02 -07:00
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
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"
2017-01-30 13:59:28 -08:00
export EDITOR='vim'
2019-04-29 11:47:13 -07:00
export CC="$(has clang || has gcc)"
export CXX="$(has clang++ || has g++)"
export CXXFLAGS="$CFLAGS"
2014-01-14 09:17:22 -08:00
export MAKEFLAGS="-j2"
2017-01-30 13:59:28 -08:00
export OMP_NUM_THREADS=4
2015-04-06 12:12:06 -07:00
export VST_SDK_DIR="$HOME/src/vstsdk2.4"
export LADSPA_PATH="/usr/lib/ladspa"
2017-01-23 11:56:26 -08:00
export NQDIR="$HOME/play"
2013-06-28 05:22:14 -07:00
2018-02-21 01:43:05 -08:00
# enable colors
2013-06-28 05:22:14 -07:00
for x in ls dir vdir grep fgrep egrep; do
alias $x="$x --color=auto"
done
2016-12-09 17:19:28 -08:00
unset x
2019-04-29 11:47:31 -07:00
alias lr="lr -G"
2013-11-11 15:11:22 -08:00
#alias make="$(has colormake || has make)"
2013-06-28 05:22:14 -07:00
# just flags
2018-04-11 15:46:09 -07:00
export LESS='-SRQ'
2015-05-06 09:33:03 -07:00
alias db="dropbox_uploader"
2017-03-29 00:52:37 -07:00
alias fils="du -bahd1"
2013-06-28 05:22:14 -07:00
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"
2019-05-27 10:13:09 -07:00
alias get="git clone --single-branch --depth 1"
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'
2019-05-27 10:13:09 -07:00
alias glo='git log --graph --decorate --pretty=oneline --abbrev-commit --all'
alias perlu='perl -Mopen=locale -Mutf8'
2019-05-21 01:33:18 -07:00
alias rgn="rg --no-ignore"
2019-05-30 01:27:12 -07:00
alias cms="cryptominisat5 --verb 0"
2013-06-28 05:22:14 -07:00
2016-08-27 23:45:42 -07:00
whoa=(
-Wall
-Wextra
# -Winline # only for C
# -Wshadow # only for C
2016-09-19 13:04:10 -07:00
-Wwrite-strings
2017-04-18 20:12:14 -07:00
# -Wmissing-prototypes
2016-09-19 13:04:10 -07:00
-Werror=implicit-function-declaration
-Werror=uninitialized
-Werror=format-security
-Werror=format-extra-args
2017-04-18 20:12:14 -07:00
-Werror=pointer-to-int-cast
-Werror=int-to-pointer-cast
2017-05-03 01:00:55 -07:00
-Werror=return-type
2017-10-05 05:08:08 -07:00
-Werror=memset-transposed-args
2017-05-25 19:25:05 -07:00
# -Werror=tautological-constant-out-of-range-compare # gcc doesn't like this
# -Werror=undef
2016-08-27 23:45:42 -07:00
-Wno-unused
-Wno-padded
-Wno-missing-field-initializers
2017-10-05 05:08:08 -07:00
# -Wno-type-limits # bad for generated code (macros, templates)
2016-08-27 23:45:42 -07:00
-Wno-misleading-indentation # gcc 6
-Wno-disabled-macro-expansion # clang
-Wno-language-extension-token # clang
-Wno-unknown-warning-option # clang
2017-10-05 05:08:08 -07:00
# trying some stuff:
-Wduplicated-cond # gcc 6
-Wduplicated-branches # gcc 7
-Wlogical-op
-Wrestrict # gcc 7
-Wnull-dereference # gcc 6
2017-11-02 08:14:08 -07:00
#-Wjump-misses-init # only for C
2017-10-05 05:08:08 -07:00
-Wdouble-promotion
-Wformat=2
2016-08-27 23:45:42 -07:00
)
2017-03-29 00:52:37 -07:00
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
)
2019-06-03 09:26:26 -07:00
if which sudo >/dev/null 2>/dev/null; then
alias maybesudo=sudo
else
function maybesudo() {
while [[ "$1" == -* ]]; do shift; done
"$@"
}
fi
2013-06-28 05:22:14 -07:00
# being specific
2019-05-27 03:03:13 -07:00
[ -e "$HOME/python3" ] && alias py="~/python3" || alias py="python3"
2019-06-03 09:26:26 -07:00
alias pip="maybesudo -H pip3"
2017-01-30 13:59:28 -08:00
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'
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"
2019-06-03 09:26:26 -07:00
alias clone='maybesudo rsync -aHA --info=progress2 --no-i-r'
2016-01-11 04:03:19 -08:00
alias meow='( cd ~/play/meow; ~/sh/meow.sh/run -pa )'
2017-04-30 17:48:11 -07:00
alias aligntabs="column -t -s$'\t'"
2019-04-29 11:47:31 -07:00
alias gc="git column --mode=dense --padding=2"
2019-05-27 03:03:13 -07:00
alias pippy="py -m pip install --upgrade --upgrade-strategy only-if-needed"
2019-04-29 11:47:31 -07:00
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
}
2016-01-11 04:03:19 -08:00
# providing extra functionality
2013-06-28 05:22:14 -07:00
alias counts='find . | wc -l'
alias exts='print -l *(:e:l) | sort | uniq -c | sort -n'
2016-01-11 04:03:19 -08:00
alias freq="cut -d' ' -f1 < ~/.histfile | sort | uniq -c | sort -rn | head"
#
alias nocom='egrep -v --line-buffered --color=never "^[[:space:]]*(//|#)"'
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'
2016-01-11 04:03:19 -08:00
alias cleanse='tr -cd "\11\12\15\40-\176"'
alias rot13='tr "A-Za-z0-9" "N-ZA-Mn-za-m5-90-4"'
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"}'\'
2017-03-06 02:39:48 -08:00
alias double='awk "{print;print}"'
2018-07-08 23:22:42 -07:00
alias join2='paste -d" " - -'
alias katagana='perlu -MUnicode::Normalize -pe'"'"'$_=NFKD($_)=~y/ァ-ヶ /ぁ-ゖ /r'"'"
2016-01-11 04:03:19 -08:00
#
2017-03-06 02:39:48 -08:00
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'
2016-01-11 04:03:19 -08:00
#
2019-06-03 09:26:26 -07:00
alias makepkgf='maybesudo -u $USER makepkg -Af --skipchecksums --skippgpcheck'
2014-06-02 06:54:57 -07:00
alias rakef='rake && gem build *.gemspec && gem install *.gem'
2016-10-10 08:40:26 -07:00
trash() {
2014-06-02 06:54:57 -07:00
dd status=none if=/dev/random bs=1 count="$1"
}
2013-06-28 05:22:14 -07:00
2016-10-24 00:41:37 -07:00
unset cdrive
2018-08-03 20:45:30 -07:00
unset ddrive
2016-10-24 00:41:37 -07:00
2015-12-11 01:06:01 -08:00
. ~/.streamcrap
. ~/.ea