2021-12-11 11:49:53 +01:00
|
|
|
#! /bin/zsh
|
|
|
|
|
2018-01-29 16:10:37 +01:00
|
|
|
alias cdiff="colordiff"
|
2018-01-30 08:47:55 +01:00
|
|
|
|
2023-07-10 11:56:29 +02:00
|
|
|
alias mktemp='mktemp --suffix=.delme --tmpdir=$XDG_RUNTIME_DIR'
|
|
|
|
|
2021-12-11 11:49:53 +01:00
|
|
|
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
|
|
|
|
}
|
2018-01-30 08:47:55 +01:00
|
|
|
|
2021-12-11 11:49:53 +01:00
|
|
|
alias diff="diff -W \$(( \$(tput cols) - 2))"
|
2018-01-29 16:10:37 +01:00
|
|
|
|
|
|
|
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'
|
2018-05-29 11:35:10 +02:00
|
|
|
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
2019-02-07 11:38:17 +01:00
|
|
|
alias pygmentize='pygmentize -O style=solarizeddark'
|
2019-06-04 11:49:02 +02:00
|
|
|
alias ra='ranger'
|
2021-12-24 07:55:37 +01:00
|
|
|
alias rsync='rsync --xattrs --acls --recursive --times --perms --links --checksum --human-readable --verbose --compress --compress-level=9 --rsh=ssh'
|
2021-08-11 10:35:55 +02:00
|
|
|
alias disable_turbo='sudo sh -c "echo 1 | tee /sys/devices/system/cpu/intel_pstate/no_turbo"'
|
2021-11-23 18:58:04 +01:00
|
|
|
alias byobu-linger='systemd-run --scope --user -du byobu byobu'
|
2018-01-29 16:10:37 +01:00
|
|
|
|
2020-09-11 14:16:31 +02:00
|
|
|
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]"'
|
|
|
|
|
2018-10-15 14:29:31 +02:00
|
|
|
function mkcdir () {
|
|
|
|
mkdir -p -- "$1" &&
|
2021-12-11 11:49:53 +01:00
|
|
|
cd -P -- "$1" ||
|
|
|
|
exit 1
|
2018-10-15 14:29:31 +02:00
|
|
|
}
|
|
|
|
|
2019-07-24 13:49:49 +02:00
|
|
|
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
|
2021-12-11 11:49:53 +01:00
|
|
|
|
|
|
|
# shellcheck disable=SC2046
|
|
|
|
# Word splitting *cannot* occur in a result of `test`
|
2019-07-24 13:49:49 +02:00
|
|
|
return $(test "$ROOT_MP" -eq "$SHELL_MP")
|
|
|
|
}
|
|
|
|
|
2018-02-05 06:47:02 +01:00
|
|
|
if [ -x "$(which lsb_release)" ];
|
2018-01-29 16:10:37 +01:00
|
|
|
then
|
2021-12-11 11:49:53 +01:00
|
|
|
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
|
2018-02-03 09:56:57 +01:00
|
|
|
if [ $use_sudo -eq 1 ];
|
|
|
|
then
|
2018-02-14 10:45:09 +01:00
|
|
|
alias aar='sudo apt-get --purge autoremove'
|
2018-02-03 09:56:57 +01:00
|
|
|
alias adbu='sudo $apt_pref -t ${current_dist}-backports $apt_upgr'
|
2019-12-10 05:26:49 +01:00
|
|
|
alias drd='[ -n "$all_dkms_packages" ] && sudo dpkg-reconfigure ${all_dkms_packages%% }'
|
2018-02-03 09:56:57 +01:00
|
|
|
else
|
2018-02-14 10:45:09 +01:00
|
|
|
alias aar='su -lc "apt-get --purge autoremove"'
|
2018-02-03 09:56:57 +01:00
|
|
|
alias adbu='su -lc "$apt_pref -t ${current_dist}-backports $apt_upgr" root'
|
2019-12-10 05:26:49 +01:00
|
|
|
alias drd='[ -n "$all_dkms_packages" ] && su -lc "dpkg-reconfigure ${all_dkms_packages%% }" root'
|
2018-02-03 09:56:57 +01:00
|
|
|
fi
|
2018-01-29 16:10:37 +01:00
|
|
|
fi
|