#!/usr/bin/env bash
# vim:syntax=sh
# This file actually has aliases _and_ functions.
if [ "$TERM" != "dumb" ];then
eval "$(dircolors -b)"
alias ls="ls --color=auto"
alias grep="grep --color=auto"
alias egrep="egrep --color=auto"
fi
alias lst="ls -l --time-style=full-iso"
alias cls=' echo -ne "\033c"'
alias pip-update="sudo pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo pip install -U"
alias matrix='cmatrix -sbu6 -C cyan'
alias tbc='tbclock -e -H2 -M7 -S3'
command -v colordiff >/dev/null 2>&1&&alias diff="colordiff"
#command -v colormake >/dev/null 2>&1&&alias make="colormake"
alias perllint="perl -Mstrict -Mdiagnostics -cw"
alias scredit='gimp "${SCRSHDIR}/$(ls -rt1 $SCRSHDIR/|tail -n1)"'
alias scrview='pqiv -i "${SCRSHDIR}/$(ls -rt1 $SCRSHDIR/|tail -n1)"'
alias scrls='ls -l "${SCRSHDIR}/$(ls -rt1 $SCRSHDIR/|tail -n1)"'
alias fuck='sudo $(history -p \!\!)'
alias x509-out='openssl x509 -text -certopt no_version,no_pubkey,no_sigdump,no_aux,no_header -noout -in'
alias isocreate='rm -vf /tmp/image.iso && mkisofs -v -r -J -translation-table -hide-joliet-trans-tbl -iso-level 4 -o /tmp/image.iso'
#alias isoburn='sudo cdrecord -v -speed=10 dev=/dev/sr0 -data'
alias isoburn='sudo cdrecord -v dev=/dev/sr0 -data'
# voice messages e.g. for whatsapp (on libpurple). use "voicemsg OUTPUT.ogg"
alias voicemsg='ffmpeg -f pulse -i default -ac 1 -ar 16000 -c:a libopus -y'
if command -v colordiff > /dev/null;then alias diff="colordiff";fi
# aliases like this are relevant if you use multiple passwordstore stores, e.g.
# your common store is a department-wide one but you still need to store personal credentials
alias ppass='PASSWORD_STORE_DIR=~/.password-store pass'
alias ifs='printf "%q\\n" "$IFS "'
# ----- CHOO CHOO ----- #
if command -v sl >/dev/null;then
alias sl='sl -e'
alias LS='LS -e'
fi
# ----- LIBVIRT ----- #
alias vl="virsh list --all --title"
alias vnl="virsh net-list --all"
# shellcheck disable=SC2154
alias vifl='for i in $(virsh list --name --all);do echo $i;virsh domiflist $i;done'
# shellcheck disable=SC2154
alias vifl='for i in $(virsh list --name --all);do echo $i;virsh domiflist $i;done'
alias v='vnl;vl;vifl'
# ----- BYOBU/TMUX ----- #
alias ba='byobu has -t "$BSNAME" >/dev/null 2>&1 &&byobu list-sessions&&sleep 1&&byobu attach-session -t "$BSNAME"||printf "No session called %b!\\n" "$BSNAME"'
alias bl="byobu list-sessions"
alias bo="byobu list-sessions \; list-windows"
alias tc='tmux save-buffer -|xclip -i&&echo "tmux buffer copied"'
# ----- NETWORK ----- #
alias openports='ss --all --numeric --processes --ipv4 --ipv6'
alias myip4='curl -k "https://diagnostic.opendns.com/myip"'
alias myip6='curl -6 "https://icanhazip.com"'
# ----- MEDIA ----- #
alias dvdb='dvdbackup -i /dev/dvd1 -M'
alias dvdburn='brasero'
alias dosbox='export SDL_VIDEO_X11_DGAMOUSE=0;dosbox;unset SDL_VIDEO_X11_DGAMOUSE'
alias mdf2iso="iat"
alias bin2iso="iat"
alias replaygain='mp3gain -s i'
alias jackdrc="/usr/bin/jackd -T -u -dalsa -r48000 -p1024 -n2 -D -Chw:CODEC &>/dev/null &"
alias html2png="cutycapt"
# ----- WM ----- #
alias startgnome="sxs gnome"
alias startkde="sxs kde"
alias starte16="sxs e16"
alias startxmonad="sxs xmonad"
# ----- SSH ----- #
alias saa="source ~/.ssh/sshenv;ssh-add >/dev/null 2>&1;ssh-add -l"
alias sshr='ssh -o StrictHostKeyChecking=no'
alias sshk='ssh -o PasswordAuthentication=yes -o PreferredAuthentications=keyboard-interactive,password -o PubkeyAuthentication=no'
alias sshg="ssh-with-gpg"
function add-sshagent-init {
for KEY in "${SSHKEYS[@]}";do
FFPRINT="$(ssh-keygen -Esha256 -lf "$KEY")" || return 1
if ! ssh-add -l 2>/dev/null | grep "$FFPRINT" >/dev/null; then
ssh-add -q "$KEY"
fi
done
}
alias sshmaster='ssh -O'
# ----- FS ----- #
xstat() {
for target in "${@}";do
# shellcheck disable=SC2012
inode=$(ls -di "${target}"|cut -d ' ' -f 1)
fs=$(df "${target}"|tail -n 1|awk '{print $1}')
crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | grep -oP 'crtime.*--\s*\K.*')
printf "%s\t%s\n" "${crtime}" "${target}"
done
}
# ----- PACKAGE MANAGERS ----- #
if [ -x "/usr/bin/pikaur" ];then
alias pkgclean="pikaur --noconfirm -Sc"
elif [ -x "/usr/bin/pacman" ];then
alias pkgclean="/usr/bin/sudo /usr/bin/pacman --noconfirm -Sc"
elif [ -x "/usr/bin/apt" ];then
alias pkgclean="/usr/bin/sudo /usr/bin/apt clean"
elif [ -x "/usr/bin/dnf" ];then
alias pkgclean="/usr/bin/sudo /usr/bin/dnf clean packages"
elif [ -x "/usr/bin/zypper" ];then
alias pkgclean="/usr/bin/sudo /usr/bin/zypper clean"
fi
# ----- GRAFANA ----- #
if command -v grafana-cli >/dev/null;then
alias gfpi='sudo grafana-cli plugins install'
alias gfpl='sudo grafana-cli plugins list'
alias gfplr='sudo grafana-cli plugins list-remote'
alias gfrs="sudo systemctl restart grafana-server.service;systemctl is-active grafana-server.service;sudo ss -pantl|grep :3000"
fi
alias gfs="systemctl is-active grafana-server.service&&sudo ss -pantl|grep :3000"
# ----- ZE PASSWORDS ----- #
if [ -r "/etc/os-release" ];then
osid="$(grep ^ID /etc/os-release|awk -F= '{print $2}'|tail -n1)"
case "$osid" in
fedora|centos|rhel*)
alias mkpsk="makepasswd -c '1234567890abcdef' -l 64"
alias mkpw="makepasswd -c 'qwertzuiopasdfghjkyxcvbnmQWERTZUPASDFGHJKLYXCVBNM23456789#!_' -l 24"
;;
*suse*)
alias mkpsk="mimimi :("
alias mkpw="mimimi :("
;;
*)
alias mkpsk="makepasswd --string='1234567890abcdef' --chars='64'"
alias mkpw="makepasswd --string='qwertzuiopasdfghjkyxcvbnmQWERTZUPASDFGHJKLYXCVBNM23456789#!_' --chars='24'"
;;
esac
unset osid
fi
# ----- GPG -----#
alias gpg='gpg --expert'
gpg-expmaster() {
FRETVAL=0
HELPTXT="Exports all secrets to master file\nUSAGE:\t${FUNCNAME[0]} outputfile key-id"
[ -z "$1" ]&&echo -e "$HELPTXT"&&FRETVAL=$((FRETVAL+1))||\
[ -z "$2" ]&&echo -e "$HELPTXT"&&FRETVAL=$((FRETVAL+1))||\
gpg2 --armour --output "$1" --export-secret-key "$2"||FRETVAL=$((FRETVAL+1))
return "$FRETVAL"
}
gpg-exppaper() {
FRETVAL=0
HELPTXT="Exports all secrets to paper\nUSAGE:\t${FUNCNAME[0]} key-id"
[ -z "$1" ]&&echo -e "$HELPTXT"&&FRETVAL=$((FRETVAL+1))||\
gpg2 --export-secret-key "$1"|paperkey|lpr||FRETVAL=$((FRETVAL+1))
return "$FRETVAL"
}
gpg-removekey() {
FRETVAL=0
HELPTXT="Removes a key ID from keystore\nUSAGE:\t${FUNCNAME[0]} key-id"
[ -z "$1" ]&&echo -e "$HELPTXT"&&FRETVAL=$((FRETVAL+1))||\
gpg-connect-agent "DELETE_KEY $1" /bye||FRETVAL=$((FRETVAL+1))
return "$FRETVAL"
}
# ----- CERTIFICATES ----- #
alias certmgr='certutil -d sql:${HOME:?}/.pki/nssdb'
alias certlist="certmgr -L"
alias certshow="certmgr -L -n"
# ----- APPLICATION CONTROL ----- #
alias browser-set='xdg-settings set default-web-browser'
alias browser-get='xdg-settings get default-web-browser'
# ----- CONTAINERS ----- #
if command -v podman >/dev/null;then
alias pcl="podman container list"
alias pclj="podman container list --format json"
alias pnl="podman network ls"
alias ppl="podman pod list"
alias pplj="podman pod list --format json"
alias pvl="podman volume list"
alias pvlj="podman volume list --format json"
alias pci="podman container inspect"
alias pni="podman network inspect"
alias ppi="podman pod inspect"
alias pvi="podman volume inspect"
alias pcr="podman container rm"
alias pnr="podman network rm"
alias ppr="podman pod rm"
alias pvr="podman volume rm"
alias pcs="podman container start"
alias pnc="podman network connect"
alias pps="podman pod start"
# d=destroy, kvm's term for "stop vigorously" :-)
alias pcd="podman container stop"
alias pnd="podman network disconnect"
alias ppd="podman pod stop"
fi
for cmmd in batcat bat; do
if command -v "$cmmd" > /dev/null; then
# shellcheck disable=SC2139
alias cat="${cmmd} --tabs 4 --wrap never --paging never --style 'plain,rule'"
# shellcheck disable=SC2139
alias less="${cmmd} --tabs 4 --wrap never --paging always --style 'plain,rule'"
alias plain-cat='/usr/bin/cat'
alias plc='/usr/bin/cat'
alias plain-less='/usr/bin/less'
alias pll='/usr/bin/less'
export MANPAGER="sh -c 'col -bx | ${cmmd} -l man -p'"
export MANROFFOPT="-c"
break
fi
done
# Flake8. Nice linter, but...
# They kneeled to USER STUPIDITY when it comes to configuration. Wut?
# https://flake8.pycqa.org/en/latest/release-notes/4.0.0.html#backwards-incompatible-changes
# --> https://github.com/pycqa/flake8/pull/1404
# Users were confused, so ~/.config/flake8 is not supported anymore. lelkek.
alias flake8='flake8 --config ${HOME}/.config/flake8'
1.5em;
width:1.5em;height:1.5em;text-align:center;margin:0 auto;padding:0;display:block;
}
#hots p#hotslogs {text-align:center; margin:0 auto;margin-bottom:1em;}
#rebuild {text-decoration:blink;color:#30c000;}
#os-releases {/*width:66.6%;*/margin-left:2em;}
#os-releases th {text-align:left;}
#os-releases tr:nth-child(2n-1) td {background-color:#bcd1c1;}
#os-releases tr td,#os-releases tr th {padding:0 0.75em;}
#os-releases tr td.hash {font-family:"DejaVu Sans Mono",Monospace,monospace,serif;font-size:90%;}
#nowww {
position:fixed;top:4em;right:1em;margin:0;padding:0;
background:transparent url('/assets/no_www.png') bottom right no-repeat;
background-size:80px auto;width:80px;height:80px;
}
#nowww a {
display:block;margin:0;padding:0;
width:80px;height:80px;
}
#nowww a span {display:none;}
div.markdown-body p:last-child { padding-bottom:1.5em; }
div#cgit {margin-bottom:2em;}
@keyframes fadeDown {
0% {
opacity: 0;
transform: translateY(-20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
.fadeDown, header {
animation:fadeDown 1s ease;
}
/* jekyll */
header.post-header { margin-top: 0.1337em; }
.post h1 { font-size:2.1337em; text-align: left; }
.post h1+p { text-align: left; }
ul.post-list {
background: #f0f0f0;
list-style: none;
padding-inline-start: 0;
padding: 0.8em;
}
ul.post-list li { padding:0.4em; }
ul.post-list li:nth-child(2n-1) { background-color:#ffffff; }
ul.post-list li span.post-meta {
font-weight: bold;font-style: oblique;font-size:100%;
}
ul.post-list li span.post-meta:after { content: ':'; }
ul.post-list li h3 {
font-size: 100%;font-weight: normal; display: inline;
margin-left: 1em;
font-family: "Telex","Helvetica Neue",Helvetica,Arial,sans-serif;
border-bottom: none;
}
ul.post-list li h3 a {
text-decoration: none;
}
nav.blog-nav {
background: transparent;
position: static;
border: none;
}
.blog-nav .nav-trigger { display:none; }
.blog-nav .menu-icon { display:none; }
.post-content table {
margin-bottom: 30px;
width: 100%;
text-align: left;
color: #3f3f3f;
border-collapse: collapse;
border: 1px solid #d0d0d0; }
.post-content table tr:nth-child(odd) {
background-color: #e0e0e0; }
.post-content table tr:nth-child(even) {
background-color: #f0f0f0; }
.post-content table th, table td {
padding: 10px 15px; }
.post-content table th {
background-color: #f0f0f0;
border: 1px solid #dedede;
border-bottom-color: #c9c9c9; }
.post-content table td {
border: 1px solid #e8e8e8; }
.blog-nav a.page-link {
text-decoration: none;
font-size:110%;
border-left: 1px solid;
border-right: 1px solid;
margin-left: 0.1em;margin-right:0.1em;
padding-left:0.7331em;padding-right: 0.7331em;
display: inline-block;
}
.blog-nav a.page-link:first-child {
margin-left: 0;
border-left: 0;
}
.blog-nav a.page-link:last-child {
margin-right: 0;
border-right: 0;
}
figure.highlight {
margin: 0 auto;
margin-left: 1em;
padding: 0.666em;
}
figure.highlight pre {
margin-top: 0;
margin-bottom: 0;
overflow-x: auto;
overflow-y: hidden;
}
figure.highlight pre code, code.highlighter-rouge {
font-size: 0.8em;
}
article.post div.post-content, #tocw {
background: rgba(251,255,253,0.6);
padding: 0.666em;
}
main.page-content a, footer.site-footer a {
text-decoration: none;
color: #169b62;
font-weight: 550;
}
main.page-content a:hover, footer.site-footer a:hover, main.page-content a:active,
footer.site-footer a:active {
color: #ff883e;
}
.highlight { background: #e8fff0; }
#tocw ol {
list-style-type: decimal;
counter-reset: item;
padding-left: 10px;
}
#tocw ol li {
display: block;
}
#tocw > ol > li {
padding-left: 0.5em;
}
#tocw > ol > li > ol > li {
padding-left: 0.666em;
}
#tocw > ol > li > ol > li > ol > li {
padding-left: 1.337em;
}
#tocw ol li:before {
content: counters(item, ".") ". ";
counter-increment: item
}
/*main.page-content h2:before {
content: counter(heading)". ";
counter-increment: heading;
}
main.page-content h2 {
counter-reset: subheading;
}
main.page-content h3:before {
content: counter(heading)"." counter(subheading)". ";
counter-increment: subheading;
}*/
/**
* Syntax highlighting styles
*/
.highlight {
background: #fff; }
.highlighter-rouge .highlight {
background: #eef; }
.highlight .c {
color: #998;
font-style: italic; }
.highlight .err {
color: #a61717;
background-color: #e3d2d2; }
.highlight .k {
font-weight: bold; }
.highlight .o {
font-weight: bold; }
.highlight .cm {
color: #998;
font-style: italic; }
.highlight .cp {
color: #999;
font-weight: bold; }
.highlight .c1 {
color: #998;
font-style: italic; }
.highlight .cs {
color: #999;
font-weight: bold;
font-style: italic; }
.highlight .gd {
color: #000;
background-color: #fdd; }
.highlight .gd .x {
color: #000;
background-color: #faa; }
.highlight .ge {
font-style: italic; }
.highlight .gr {
color: #a00; }
.highlight .gh {
color: #999; }
.highlight .gi {
color: #000;
background-color: #dfd; }
.highlight .gi .x {
color: #000;
background-color: #afa; }
.highlight .go {
color: #888; }
.highlight .gp {
color: #555; }
.highlight .gs {
font-weight: bold; }
.highlight .gu {
color: #aaa; }
.highlight .gt {
color: #a00; }
.highlight .kc {
font-weight: bold; }
.highlight .kd {
font-weight: bold; }
.highlight .kp {
font-weight: bold; }
.highlight .kr {
font-weight: bold; }
.highlight .kt {
color: #458;
font-weight: bold; }
.highlight .m {
color: #099; }
.highlight .s {
color: #d14; }
.highlight .na {
color: #008080; }
.highlight .nb {
color: #0086B3; }
.highlight .nc {
color: #458;
font-weight: bold; }
.highlight .no {
color: #008080; }
.highlight .ni {
color: #800080; }
.highlight .ne {
color: #900;
font-weight: bold; }
.highlight .nf {
color: #900;
font-weight: bold; }
.highlight .nn {
color: #555; }
.highlight .nt {
color: #000080; }
.highlight .nv {
color: #008080; }
.highlight .ow {
font-weight: bold; }
.highlight .w {
color: #bbb; }
.highlight .mf {
color: #099; }
.highlight .mh {
color: #099; }
.highlight .mi {
color: #099; }
.highlight .mo {
color: #099; }
.highlight .sb {
color: #d14; }
.highlight .sc {
color: #d14; }
.highlight .sd {
color: #d14; }
.highlight .s2 {
color: #d14; }
.highlight .se {
color: #d14; }
.highlight .sh {
color: #d14; }
.highlight .si {
color: #d14; }
.highlight .sx {
color: #d14; }
.highlight .sr {
color: #009926; }
.highlight .s1 {
color: #d14; }
.highlight .ss {
color: #990073; }
.highlight .bp {
color: #999; }
.highlight .vc {
color: #008080; }
.highlight .vg {
color: #008080; }
.highlight .vi {
color: #008080; }
.highlight .il {
color: #099; }
git.lirion.de
Of git, get, and gud
blob: a8fb3ef7830a6db9d375c08e62d5ee8334b3cac2 (
plain)