2020-12-29 08:38:07 -08:00
|
|
|
#!/usr/bin/env zsh
|
2021-07-29 00:37:35 -07:00
|
|
|
# for zsh, bash, and dash.
|
2019-06-12 18:11:23 -07:00
|
|
|
[ -n "$ZSH_VERSION" -o -n "$BASH" ] && FANCY=1 || FANCY=0
|
2013-06-28 05:22:14 -07:00
|
|
|
|
2019-06-12 18:11:23 -07:00
|
|
|
# {{{1 utilities
|
2013-06-28 05:22:14 -07:00
|
|
|
|
2021-07-29 00:37:35 -07:00
|
|
|
#SOURCING=$((SOURCING+1))
|
|
|
|
#. ~/sh/ify
|
|
|
|
#. ~/sh/has
|
|
|
|
#. ~/sh/maybesudo
|
|
|
|
#SOURCING=$((SOURCING-1))
|
|
|
|
|
|
|
|
# not available in busybox:
|
|
|
|
#exports() {
|
|
|
|
# printenv | cut -d= -f1
|
|
|
|
#}
|
2019-06-12 18:11:23 -07:00
|
|
|
|
2021-07-29 00:37:35 -07:00
|
|
|
if has sudo >/dev/null; then
|
2019-06-12 18:11:23 -07:00
|
|
|
alias maybesudo=sudo
|
|
|
|
else
|
2021-07-29 00:37:35 -07:00
|
|
|
alias maybesudo="maybesudo_ " # allows aliases within the alias
|
2019-06-12 18:11:23 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
ADDPATH() {
|
|
|
|
new="$(readlink -f "$1")"
|
2021-07-21 15:30:05 -07:00
|
|
|
if [ ! -d "$new" ]; then
|
|
|
|
echo -E "ADDPATH: path doesn't exist: $1" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
2019-06-12 18:11:23 -07:00
|
|
|
echo ":$PATH:" | grep -q ":$new:" || export PATH="$PATH:$new"
|
|
|
|
}
|
|
|
|
|
|
|
|
# shortcuts {{{1
|
2019-06-03 09:27:20 -07:00
|
|
|
|
|
|
|
if [ $FANCY -eq 1 ]; then
|
|
|
|
# these drive letters only help because of a bug in my zsh completions...
|
|
|
|
hash -d c="/c"
|
|
|
|
hash -d d="/d"
|
|
|
|
[ -d /media/chibi ] && hash -d e="/media/chibi" || hash -d e="/e"
|
2021-07-21 15:30:05 -07:00
|
|
|
hash -d s="/s"
|
2019-06-03 09:27:20 -07:00
|
|
|
|
|
|
|
hash -d cyg=~c"/cygwin/home/$USER"
|
|
|
|
hash -d msys=~c"/msys64/home/$USER"
|
|
|
|
hash -d win=~c"/Users/$USER"
|
|
|
|
hash -d mm=~c"/Program Files (x86)/mupen64plus/mm"
|
|
|
|
hash -d py=~win"/Dropbox/py"
|
|
|
|
fi
|
2015-03-07 07:57:26 -08:00
|
|
|
|
2019-06-12 18:11:23 -07:00
|
|
|
# {{{1 configurations
|
|
|
|
|
|
|
|
# umask should be reset else pip might make faulty installations.
|
|
|
|
umask 022
|
|
|
|
|
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"
|
2021-07-21 15:30:05 -07:00
|
|
|
[ -n "$MSYSTEM" ] && ADDPATH "/c/Program Files/7-Zip-Zstandard" 2>/dev/null
|
|
|
|
[ -n "$MSYSTEM" ] && ADDPATH ~win"/Desktop/_programs/rakudo-2021.06/bin" 2>/dev/null
|
2013-06-29 11:47:01 -07:00
|
|
|
|
2021-07-29 00:37:35 -07:00
|
|
|
# for dash:
|
|
|
|
export ENV="$HOME/.-shrc"
|
|
|
|
|
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-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
|
|
|
|
2014-02-24 14:15:53 -08:00
|
|
|
# PuTTY over serial
|
2020-08-25 23:37:28 -07:00
|
|
|
test "$TERM" = vt102 && export TERM="xterm"
|
2014-02-24 14:15:53 -08:00
|
|
|
|
2015-05-06 09:33:03 -07:00
|
|
|
# Qt is stupid and thinks we're running unity so it hides the menu bar
|
2020-08-25 23:37:28 -07:00
|
|
|
test "$DESKTOP_SESSION" = xfce && export QT_QPA_PLATFORMTHEME=""
|
2015-05-06 09:33:03 -07:00
|
|
|
|
2019-07-13 08:29:03 -07:00
|
|
|
export EDITOR=vim
|
2019-07-13 08:29:45 -07:00
|
|
|
export PAGER=less
|
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"
|
2017-01-23 11:56:26 -08:00
|
|
|
export NQDIR="$HOME/play"
|
2013-06-28 05:22:14 -07:00
|
|
|
|
2019-06-12 18:11:23 -07:00
|
|
|
if [ "$LANG" != "en_US.UTF-8" ] && [ "$LANG" != "en_CA.UTF-8" ]; then
|
|
|
|
if [ -z "$MSYSTEM" ] || [ "$LANG" != "C.UTF-8" ]; then
|
|
|
|
if [ -z "$LANG" ]; then
|
|
|
|
echo -E "Warning: LANG is empty!" >&2
|
|
|
|
else
|
|
|
|
echo -E "Warning: LANG is $LANG" >&2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# aliases {{{1
|
|
|
|
|
|
|
|
# enable colors {{{2
|
|
|
|
|
2019-06-05 21:49:21 -07:00
|
|
|
(echo test | grep --color=auto blah >/dev/null 2>&1) && alias grep='grep --color=auto'
|
|
|
|
(ls --color=auto >/dev/null 2>&1) && alias ls='ls --color=auto'
|
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
|
|
|
|
2019-06-12 18:11:23 -07:00
|
|
|
# just flags {{{2
|
|
|
|
|
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"
|
2019-06-12 18:11:23 -07:00
|
|
|
alias perlu='perl -Mopen=locale -Mutf8'
|
|
|
|
alias rgn="rg --no-ignore"
|
|
|
|
alias cms="cryptominisat5 --verb 0"
|
2020-11-04 22:48:00 -08:00
|
|
|
alias curls="curl -sS"
|
2019-06-12 18:11:23 -07:00
|
|
|
|
|
|
|
# git {{{2
|
|
|
|
|
2019-05-27 10:13:09 -07:00
|
|
|
alias get="git clone --single-branch --depth 1"
|
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'
|
2021-06-19 20:25:17 -07:00
|
|
|
alias g1='git log --pretty=oneline --abbrev-commit --color=always | head -1'
|
|
|
|
alias gr='git remote -v'
|
2019-06-05 12:35:16 -07:00
|
|
|
alias gb='git --no-pager branch'
|
2013-06-28 05:22:14 -07:00
|
|
|
|
2019-06-12 18:11:23 -07:00
|
|
|
# being specific {{{2
|
2019-06-03 09:26:26 -07:00
|
|
|
|
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"
|
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'
|
2017-04-30 17:48:11 -07:00
|
|
|
alias aligntabs="column -t -s$'\t'"
|
2019-06-12 18:16:51 -07:00
|
|
|
alias crawla='ssh joshua@crawl.akrasiac.org -i ~/.ssh/crawl'
|
|
|
|
alias crawlz='ssh crawl@crawl.develz.org -i ~/.ssh/crawl'
|
2019-04-29 11:47:31 -07:00
|
|
|
|
2020-12-29 08:38:07 -08:00
|
|
|
alias ll="lol" # workaround for a strange issue with bash
|
|
|
|
lol() {
|
2019-04-29 11:47:31 -07:00
|
|
|
{ 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
|
|
|
|
2019-06-12 18:11:23 -07:00
|
|
|
# providing extra functionality {{{2
|
|
|
|
|
2019-07-29 02:53:16 -07:00
|
|
|
alias diff="git diff --color=auto --no-ext-diff --no-index --no-prefix"
|
2019-06-12 18:11:23 -07:00
|
|
|
alias gc="git column --mode=dense --padding=2"
|
2013-06-28 05:22:14 -07:00
|
|
|
alias counts='find . | wc -l'
|
2021-06-19 20:25:17 -07:00
|
|
|
alias exts="find -type f | grep -o '\\.[^/.]*$' | sort | uniq -c | sort -n"
|
2019-06-05 21:49:21 -07:00
|
|
|
alias nocom='grep -Ev --line-buffered --color=never "^[[:space:]]*(//|#)"'
|
2020-07-24 02:41:22 -07:00
|
|
|
alias sortip="sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n"
|
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" " - -'
|
2018-02-25 03:34:46 -08:00
|
|
|
alias katagana='perlu -MUnicode::Normalize -pe'"'"'$_=NFKD($_)=~y/ァ-ヶ /ぁ-ゖ /r'"'"
|
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'
|
2021-07-29 00:37:35 -07:00
|
|
|
alias makepkgf='makepkg -Af --skipchecksums --skippgpcheck'
|
2014-06-02 06:54:57 -07:00
|
|
|
alias rakef='rake && gem build *.gemspec && gem install *.gem'
|
|
|
|
|
2020-11-05 08:09:20 -08:00
|
|
|
eashare() {
|
|
|
|
# NOTE: this only works on MSYS2 for now.
|
2021-07-21 15:30:05 -07:00
|
|
|
# NOTE: i lied, this doesn't work anymore. idk
|
2020-11-05 08:09:20 -08:00
|
|
|
local dest="${1##*/}"
|
|
|
|
eaput "$1" || return 1
|
2021-07-29 00:37:35 -07:00
|
|
|
printf "%s" "$_REMOTE_DOMAIN/$_REMOTE_DIR/$dest" >> /dev/clipboard
|
2020-11-05 08:09:49 -08:00
|
|
|
}
|