Skip to content

Instantly share code, notes, and snippets.

@ormaaj
ormaaj / profile.bash
Last active December 17, 2022 23:20
/etc/profile
#!/bin/true
# /etc/profile
if ${BASH_VERSION+\:} \false; then
[[ -o xtrace && -t /dev/fd/2 ]] && exec {BASH_XTRACEFD}>&2
\shopt -u assoc_expand_once xpg_echo localvar_unset
\shopt -s extglob lastpipe globstar expand_aliases hostcomplete histappend checkwinsize cmdhist interactive_comments lithist no_empty_cmd_completion
# Wrapper to undefine a visible local variable, even in the current stack frame. Bash-only
function unset2 { command -- unset "$@"; }
(( BASH_VERSINFO[0] <= 5 && BASH_VERSINFO[1] <=2 )) && typeset -gx BASH_COMPAT=51
@ormaaj
ormaaj / .py
Created July 19, 2022 19:33
In _hash_filter._apply_hash_filter()
(ins)root@ormaaj-laptop (3852812) /home/ormaaj # PATH=$(readlink -sne ~ormaaj/doc/programs/portage/bin):${PATH##+(:)} PYTHONPATH=$(readlink -sne ~ormaaj/doc/programs/portage/lib):${PYTHONPATH##+(:)} NOLTO= NOGRAPHITE= NOGRAPHITE2= emerge -j 1 -bav dev-lang/python
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild R ] dev-lang/python [3.11.0_beta4-r2:3.11::gentoo] USE="bluetooth examples gdbm ncurses readline sqlite ssl -build -hardened -libedit -lto -pgo -test -tk -verify-sig -wininst" 0 KiB
Total: 1 package (1 reinstall), Size of downloads: 0 KiB
Would you like to merge these packages? [Yes/No]
@ormaaj
ormaaj / .bash
Created June 22, 2022 14:58
run gpg-agent
function setupGpgAgent {
# gpg-agent uses .gnupg but will not create the directory itself for new users.
if ! { [[ -d ~/.gnupg ]] || mkdir -p -- ~/.gnupg; }; then
printf 'bashrc: %s\n' 'No ~/.gnupg directory exists and failed to create it.' >&2
return 0
fi
if [[ -t 0 ]] && { GPG_TTY=$(readlink -sne /dev/fd/0) || GPG_TTY=$(tty); }; then
export GPG_TTY
else
@ormaaj
ormaaj / dircolors.bash
Created June 6, 2022 21:11
lol dircolors
function setupDirColors {
if [[ ${FUNCNAME[0]} == "${FUNCNAME[1]}" ]]; then
typeset -n LS_COLORS=$1
typeset dirc
if dirc=$("$(type -P dircolors 2>/dev/null)" -b); then
alias export=:; eval "$dirc"; unalias export
fi
else
typeset colors ret
if ! shopt -q expand_aliases; then
#!/bin/bash
if [[ ${KSH_VERSION+${!KSH_VERSION}} == .sh.version ]]; then
typeset -n FUNCNAME=.sh.fun
if builtin pids 2>/dev/null; then
function BASHPID.get { .sh.value=$(pids -f '%(pid)d'); }
elif [[ -r /proc/self/stat ]]; then
function BASHPID.get { read -r .sh.value _ </proc/self/stat; }
else
@ormaaj
ormaaj / .xinitrc
Created April 29, 2022 14:58
xinitrc
#!/bin/bash
shopt -s extglob lastpipe
shopt -u assoc_expand_once
function xinitrc_main {
typeset myRootPath
if myRootPath=$(dirname "$(readlink -sne -- "${BASH_SOURCE[0]}")") && [[ -d $myRootPath ]]; then
source "${myRootPath}/shell/functions"
@ormaaj
ormaaj / .bash
Last active September 23, 2022 16:12
builtin loader
shopt -s lastpipe extglob globstar
shopt -u assoc_expand_once
function initializeBuiltins {
typeset -a a
typeset x y z
set +m
typeset libdir=${fsRoot%%+(/)}/usr/lib64
[[ -d ${libdir}/bash ]] || libdir=${rootPath%%+(/)}/lib64
#!/bin/ksh
typeset -T FileComparer=(
typeset src dst
typeset -a mv diff rm
compound _=(
_Bool unpackComplete=false
_Bool scanComplete=false
)
@ormaaj
ormaaj / minecraft.bash
Created December 4, 2021 01:35
minecraft function
# Stupid game.
# minecraft -c | -s [ -p ]
function minecraft {
typeset \
jvm=${JAVA_HOME}/bin/java \
worldPath=~/doc/mcdata2 \
serverPath=~/doc/programs/ServerJarStorage/Release\ 1.8/minecraft_server.jar \
clientPath=~/doc/programs/Minecraft.jar
typeset opt OPTARG OPTIND OPTERR=0
# Quickly adds world read permissions to files and world read/write permissions
# to directories recursively. «-u user[:group]» will additionally chmod files
# and directories recursively.
function fixperms {
typeset -a paths
typeset chownUserGroup
until ${1+'false'}; do
case $1 in
-u)