76 lines
2.6 KiB
Bash
76 lines
2.6 KiB
Bash
#! /bin/zsh
|
|
|
|
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
# shellcheck shell=bash
|
|
|
|
alias cdiff="colordiff"
|
|
|
|
alias mktemp='mktemp --suffix=.delme --tmpdir=$XDG_RUNTIME_DIR'
|
|
|
|
function clean-gpg () {
|
|
[ -z "$(command -v gpg2)" ] && exit 1;
|
|
for key in $(gpg2 -k | sed -rn 's/pub +[a-z0-9]+\/(0x[0-9A-Fa-f]+).*/\1/p');
|
|
do
|
|
gpg2 --quiet --no-tty --edit-key "$key" clean save
|
|
done
|
|
}
|
|
|
|
alias diff="diff -W \$(( \$(tput cols) - 2))"
|
|
|
|
alias bz2c='bzip2 --best'
|
|
alias gzc='gzip --best --no-name'
|
|
alias xzc='xz --best --extreme'
|
|
alias extip='curl -LR1fs --compressed https://ipinfo.io/ | jq -Sc'
|
|
alias jjar='java -jar'
|
|
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
|
alias pygmentize='pygmentize -O style=solarizeddark'
|
|
alias ra='ranger'
|
|
alias rsync='rsync --xattrs --acls --recursive --times --perms --links --checksum --human-readable --verbose --compress --compress-level=9 --rsh=ssh'
|
|
alias disable_turbo='sudo sh -c "echo 1 | tee /sys/devices/system/cpu/intel_pstate/no_turbo"'
|
|
alias byobu-linger='systemd-run --scope --user -du byobu byobu'
|
|
|
|
alias urldecode='python3 -c "import sys, urllib.parse as ul; [sys.stdout.write(ul.unquote_plus(l)) for l in sys.stdin]"'
|
|
alias urlencode='python3 -c "import sys, urllib.parse as ul; [sys.stdout.write(ul.quote_plus(l)) for l in sys.stdin]"'
|
|
|
|
function mkcdir () {
|
|
mkdir -p -- "$1" &&
|
|
cd -P -- "$1" ||
|
|
exit 1
|
|
}
|
|
|
|
function chrooted() {
|
|
ROOT_MP="$(awk '$5=="/" {print $1}' </proc/1/mountinfo)"
|
|
SHELL_MP="$(awk '$5=="/" {print $1}' </proc/$$/mountinfo)"
|
|
if [ "$ROOT_MP" -eq "$SHELL_MP" ];
|
|
then
|
|
echo "We are not chrooted."
|
|
else
|
|
echo "We are chrooted."
|
|
fi
|
|
|
|
# shellcheck disable=SC2046
|
|
# Word splitting *cannot* occur in a result of `test`
|
|
return $(test "$ROOT_MP" -eq "$SHELL_MP")
|
|
}
|
|
|
|
if [ -x "$(which lsb_release)" ];
|
|
then
|
|
current_dist="$(lsb_release -c -s)"
|
|
all_dkms_packages="$(apt-cache rdepends --installed dkms | sed -rn 's/^ +([^ ]+)$/\1/p' | sort -iu | tr '\n' ' ')"
|
|
|
|
# shellcheck disable=SC2154,2086
|
|
# both errors are irrelevant as we are part of a bigger infrastructure
|
|
if [ $use_sudo -eq 1 ];
|
|
then
|
|
alias aar='sudo apt-get --purge autoremove'
|
|
alias adbu='sudo $apt_pref -t ${current_dist}-backports $apt_upgr'
|
|
alias drd='[ -n "$all_dkms_packages" ] && sudo dpkg-reconfigure ${all_dkms_packages%% }'
|
|
else
|
|
alias aar='su -lc "apt-get --purge autoremove"'
|
|
alias adbu='su -lc "$apt_pref -t ${current_dist}-backports $apt_upgr" root'
|
|
alias drd='[ -n "$all_dkms_packages" ] && su -lc "dpkg-reconfigure ${all_dkms_packages%% }" root'
|
|
fi
|
|
fi
|