mirror of
https://github.com/notwa/rc
synced 2024-11-05 06:39:02 -08:00
176 lines
5.6 KiB
Text
176 lines
5.6 KiB
Text
#!/usr/bin/env false
|
|
# for zsh, bash, and dash.
|
|
[ -n "$ZSH_VERSION" -o -n "$BASH" ] && FANCY=1 || FANCY=0
|
|
|
|
# {{{1 utilities
|
|
|
|
if [ -z "$ZSH_VERSION" ]; then
|
|
has() { # hardcode this function from ~/sh/has for convenience
|
|
which "$1" >/dev/null 2>&1 && which "$1"
|
|
}
|
|
fi
|
|
|
|
# not available in busybox:
|
|
#exports() {
|
|
# printenv | cut -d= -f1
|
|
#}
|
|
|
|
if has sudo >/dev/null; then
|
|
alias maybesudo=sudo
|
|
else
|
|
alias maybesudo="maybesudo_ " # allows aliases within the alias
|
|
fi
|
|
|
|
ADDPATH() {
|
|
new="$(readlink -f "$1")"
|
|
if [ ! -d "$new" ]; then
|
|
echo -E "ADDPATH: path doesn't exist: $1" >&2
|
|
return 1
|
|
fi
|
|
echo ":$PATH:" | grep -q ":$new:" || export PATH="$PATH:$new"
|
|
}
|
|
|
|
# shortcuts {{{1
|
|
|
|
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"
|
|
hash -d s="/s"
|
|
|
|
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
|
|
|
|
# {{{1 configurations
|
|
|
|
# umask should be reset else pip might make faulty installations.
|
|
umask 022
|
|
|
|
ADDPATH "$HOME/opt/local/bin"
|
|
[ -n "$MSYSTEM" ] && ADDPATH "/c/path"
|
|
[ -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
|
|
|
|
# for dash:
|
|
export ENV="$HOME/.-shrc"
|
|
|
|
# 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
|
|
|
|
# cleanup in case of inherited exports
|
|
unset PREFIX CC CPP CXX LD CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
|
|
unset AR RANLIB RC WINDRES OBJDUMP OBJCOPY
|
|
unset LD_LIBRARY_PATH
|
|
|
|
# PuTTY over serial
|
|
test "$TERM" = vt102 && export TERM="xterm"
|
|
|
|
# Qt is stupid and thinks we're running unity so it hides the menu bar
|
|
test "$DESKTOP_SESSION" = xfce && export QT_QPA_PLATFORMTHEME=""
|
|
|
|
export EDITOR=vim
|
|
export PAGER=less
|
|
export VST_SDK_DIR="$HOME/src/vstsdk2.4"
|
|
export LADSPA_PATH="/usr/lib/ladspa"
|
|
export NQDIR="$HOME/play"
|
|
|
|
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
|
|
|
|
(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'
|
|
alias lr="lr -G"
|
|
#alias make="$(has colormake || has make)"
|
|
|
|
# just flags {{{2
|
|
|
|
export LESS='-SRQ'
|
|
alias db="dropbox_uploader"
|
|
alias fils="du -bahd1"
|
|
alias lsa="ls -A --group-directories-first"
|
|
alias perlu='perl -Mopen=locale -Mutf8'
|
|
alias rgn="rg --no-ignore"
|
|
alias cms="cryptominisat5 --verb 0"
|
|
alias curls="curl -sS"
|
|
|
|
# git {{{2
|
|
|
|
alias get="git clone --single-branch --depth 1"
|
|
alias gs='git status' # rip ghostscript
|
|
alias gd='git diff -U2'
|
|
alias gds='git --no-pager diff --stat'
|
|
alias gl='git log --oneline'
|
|
alias glo='git log --graph --decorate --pretty=oneline --abbrev-commit --all'
|
|
alias g1='git log --pretty=oneline --abbrev-commit --color=always | head -1'
|
|
alias gr='git remote -v'
|
|
alias gb='git --no-pager branch'
|
|
|
|
# being specific {{{2
|
|
|
|
[ -e "$HOME/python3" ] && alias py="~/python3" || alias py="python3"
|
|
alias pip="maybesudo -H pip3"
|
|
alias revend='objcopy -I binary -O binary --reverse-bytes=4'
|
|
alias aur="BUILDDIR=$HOME/src $HOME/sh/aur -jj"
|
|
alias clone='maybesudo rsync -aHA --info=progress2 --no-i-r'
|
|
alias aligntabs="column -t -s$'\t'"
|
|
alias crawla='ssh joshua@crawl.akrasiac.org -i ~/.ssh/crawl'
|
|
alias crawlz='ssh crawl@crawl.develz.org -i ~/.ssh/crawl'
|
|
|
|
alias ll="lol" # workaround for a strange issue with bash
|
|
lol() {
|
|
{ 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 {{{2
|
|
|
|
alias diff="git diff --color=auto --no-ext-diff --no-index --no-prefix"
|
|
alias gc="git column --mode=dense --padding=2"
|
|
alias counts='find . | wc -l'
|
|
alias exts="find -type f | grep -o '\\.[^/.]*$' | sort | uniq -c | sort -n"
|
|
alias nocom='grep -Ev --line-buffered --color=never "^[[:space:]]*(//|#)"'
|
|
alias sortip="sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n"
|
|
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='makepkg -Af --skipchecksums --skippgpcheck'
|
|
alias rakef='rake && gem build *.gemspec && gem install *.gem'
|
|
|
|
eashare() {
|
|
# NOTE: this only works on MSYS2 for now.
|
|
# NOTE: i lied, this doesn't work anymore. idk
|
|
local dest="${1##*/}"
|
|
eaput "$1" || return 1
|
|
printf "%s" "$_REMOTE_DOMAIN/$_REMOTE_DIR/$dest" >> /dev/clipboard
|
|
}
|