git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/.bash/aliases.bash
blob: 2d71298197d5e42d07a430a0ddde968b54a613b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2022-07-16 11:13:52 +0200
committer id='n51' href='#n51'>51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
#!/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 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'
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 fuck='sudo $(history -p \!\!)'
alias x509-out='openssl x509 -text -certopt no_version,no_pubkey,no_sigdump,no_aux,no_header -noout -in'
# ----- 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
		ssh-add "$KEY"
	done
}
# ----- 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 --no-confirm -Sc"
elif [ -x "/usr/bin/pacman" ];then
	alias pkgclean="/usr/bin/sudo /usr/bin/pacman --no-confirm -Sc"
elif [ -x "/usr/bin/apt" ];then
	alias pkgclean="/usr/bin/sudo 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