aliases.zsh (13908B)
1 # ██ 2 # ░██ 3 # ██████ ██████░██ 4 # ░░░░██ ██░░░░ ░██████ 5 # ██ ░░█████ ░██░░░██ 6 # ██ ░░░░░██░██ ░██ 7 # ██████ ██████ ░██ ░██ 8 # ░░░░░░ ░░░░░░ ░░ ░░ 9 # s h e l l a l i a s e s 10 # 11 # author ▓▒ pyratebeard 12 # code ▓▒ https://git.pyratebeard.net/dotfiles/file/zsh/.zsh/aliases.zsh.html 13 # colours 14 red="\e[31m" 15 green="\e[32m" 16 reset="\e[0m" 17 18 # ▓▓▒░ root 19 # check for doas so aliases can be used on different systems 20 # add whitespace for hack to make aliases woth with {sudo,doas} 21 command -v doas >/dev/null && \ 22 alias sudo='doas ' || \ 23 alias sudo='sudo ' 24 25 # ▓▓▒░ unix 26 # openbsd's ls(1) doesn't provide the `--color` option. 27 # i have grown to like this and spent a long time 28 # trying to find a work around, but none exists tiko. 29 # so i succumbed to installing coreutils and doing this 30 command -v gls >/dev/null && \ 31 alias ls="gls -hF --color=auto" || \ 32 alias ls="ls -hF --color=auto" 33 34 # i also need dircolors(1) from coreutils for zsh autocompletion 35 command -v gdircolors >/dev/null && alias dircolors="gdircolors" 36 37 # i make use of some funky shit in my log makefiles 38 # which isn't possible using the openbsd make(1) 39 command -v gmake >/dev/null && alias make='gmake' 40 41 42 # ▓▓▒░ sys 43 alias \ 44 ll="ls -lahF --color=auto" \ 45 lsl="ls -lhF --color=auto" \ 46 llrt="ls -lahFrt --color=auto" \ 47 \ 48 cp="cp -r" \ 49 rmrf="rm -rf" \ 50 scp="scp -r" \ 51 \ 52 up="cd ../" \ 53 mkdir="mkdir -p" \ 54 \ 55 xsel="xsel -b" \ 56 fuck='sudo $(fc -ln -1)' \ 57 dd="dd status=progress" \ 58 \ 59 term="urxvtc -hold -e " \ 60 \ 61 reboot="sudo reboot" \ 62 systemctl="sudo systemctl" 63 64 65 # ▓▓▒░ info 66 alias \ 67 psef="ps -ef" \ 68 jobs="jobs -l" \ 69 \?is="whereis" \ 70 history="history -i" \ 71 disks='echo "┌──┄";echo "├┄ m o u n t . p o i n t s"; echo "└──┄┄────┄┄"; lsblk -a; echo ""; echo "┌──┄";echo "├┄ d i s k . u s a g e"; echo "└──┄┄────┄┄"; sudo df -h -x tmpfs -x devtmpfs;' \ 72 ag="ag --color --color-line-number '0;35' --color-match '46;30' --color-path '4;36'" \ 73 tree='tree -CAFa -I "CVS|*.*.package|.svn|.git|.hg|node_modules|bower_components" --dirsfirst' 74 75 76 # ▓▓▒░ almighty text editor 77 alias \ 78 v="nvim" \ 79 vi="nvim" \ 80 emacs="nvim" 81 82 # ▓▓▒░ git 83 alias \ 84 g="git" \ 85 ga="git add" \ 86 gb="git branch" \ 87 gc="git commit -S -m" \ 88 gs="git status -sb" \ 89 gd="git diff" \ 90 gf="git fetch && git log --pretty=format:'%C(always,yellow)%h%Creset %s %Cred%d' ..@{u}" \ 91 gm="git merge" \ 92 gr="git rebase" \ 93 gp="git push" \ 94 gu="git unstage" \ 95 gg="git log --graph" \ 96 gco="git checkout" \ 97 gsm="git status -sbuno" \ 98 gpr="git request-pull" \ 99 ggg="git graphgpg" 100 101 gcl() { 102 git clone "${@}" 103 test -n "${2}" && _dir=${2} || _dir=${1##*/} 104 cd ${_dir%.git} 105 } 106 107 108 # ▓▓▒░ pacman 109 alias \ 110 pac="sudo pacman" \ 111 pacman="sudo pacman" \ 112 update="sudo paccache -r ; pacman -S --noconfirm archlinux-keyring ; pacman -Syu" 113 114 115 # ▓▓▒░ net 116 alias \ 117 ss="sudo ss" \ 118 netctl="sudo netctl" \ 119 openvpn="sudo openvpn" \ 120 hs="headscale" \ 121 # need ot find a better way to do this 122 #iip="ip a s $(ip r | grep default | grep -oP '(?<=dev )[^ ]*')" \ 123 failover="sudo ip link set enp5s0 down" \ 124 failback="sudo ip link set enp5s0 up" 125 126 127 # ▓▓▒░ devops 128 alias \ 129 ap="ansible-playbook" \ 130 \ 131 lxc-ls="lxc-ls -f" \ 132 lxls="lxc-ls -f" \ 133 lxst="lxc-start" \ 134 lxsp="lxc-stop" \ 135 lxat="lxc-attach" \ 136 \ 137 docker="sudo docker" \ 138 docker-compose="sudo docker-compose" \ 139 dtail="docker logs -tf --tail='50'" \ 140 dps="docker ps" \ 141 dpsa="docker ps -a" \ 142 dstart="docker start" \ 143 dstop="docker stop" \ 144 drm="docker rm" \ 145 drmi="docker rmi" \ 146 dcomp="docker-compose -f ./docker-compose.yml" \ 147 \ 148 tf="terraform" \ 149 tfi="terraform init" \ 150 tfa="terraform apply --auto-approve" \ 151 tfp="terraform plan" \ 152 tfd="terraform destroy" \ 153 \ 154 kc="KUBECONFIG=./kubeconfig.yml kubectl" 155 156 157 # ▓▓▒░ recording 158 159 alias \ 160 record="ffmpeg -f x11grab -s 1366x768 -an -r 16 -loglevel quiet -i :0.0 -b:v 5M -y" 161 162 # record the primary screen 163 screencast() { 164 test $1 && NAME=$1 || NAME="screencast" 165 RESOLUTION=$(xrandr | grep "*" | awk '{print $1}' | head -n1) 166 echo "recording to ${HOME}/lib/videos/recordings/screencasts/$(date +%Y%m%d)-${NAME}.webm" 167 ffmpeg -f x11grab -s ${RESOLUTION} -an -r 16 -loglevel quiet -i :0.0 -b:v 5M -y ${HOME}/lib/videos/recordings/screencasts/$(date +%Y%m%d)-${NAME}.webm 168 } 169 170 # take picture with webcam 171 webcapture() { 172 NUM=$(ls -l $HOME/tmp/*webcapture*|wc -l) 173 NUM=$(( NUM + 1 )) 174 ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:2 -frames 1 $HOME/tmp/$(date +%Y%m%d)-webcapture-${NUM}.png 175 } 176 177 178 # ▓▓▒░ suffix 179 alias -s \ 180 md=nvim \ 181 {png,jpg,jpeg}=sxiv \ 182 pdf=zathura \ 183 mp4=mpv 184 185 186 # ▓▓▒░ misc 187 alias \ 188 mixer="alsamixer" \ 189 news="newsboat" \ 190 gifview="gifview -a" \ 191 \ 192 headsetbatt="bluetooth_battery 34:DF:2A:5F:04:2C" \ 193 headset="echo 'connect 34:DF:2A:5F:04:2C' | bluetoothctl" \ 194 bton="echo 'power on' | bluetoothctl" \ 195 btoff="echo 'power off' | bluetoothctl" \ 196 \ 197 nodisturb="dunstctl set-paused true" \ 198 disturb="dunstctl set-paused false" \ 199 \ 200 sacc="PAGER=less sacc" \ 201 gopher="PAGER=less sacc g.nixers.net/1/~pyratebeard/startpage.gph" \ 202 buku="buku --np" \ 203 tin="NNTPSERVER=eu.newsdemon.com ~/.local/src/warez/tin/tin-latest/src/tin -r -A"\ 204 drawterm="drawterm -h 9p.sdf.org -a 9p.sdf.org -u pyratebeard" \ 205 \ 206 kb="keybase" \ 207 irc="mosh irclient -- ksh -c 'dtach -A /tmp/irc irssi'" \ 208 feh="feh -g 640x480" \ 209 rum.sh="nc rum.sh 9999" \ 210 moebius="cd $HOME/.local/src/warez/moebius ; /usr/bin/npm start" \ 211 cointop="$HOME/.local/src/go/bin/cointop --hide-statusbar" \ 212 \ 213 calendar="nvim +/$(date -I) $HOME/.local/var/notes/calendar.txt" \ 214 215 # ▓▓▒░ fun(ctions) 216 217 email() { 218 echo $3 | mutt -s $2 $1 219 } 220 221 # connect to tmux on ssh 222 # host autocomplete - $HOME/.zsh/completion/_ssux 223 ssux() { 224 test $# -gt 0 && SYSTEM="$@" || SYSTEM=$(tmux list-windows | awk '/*/{print $2}' | tr -d '*') 225 TERM=screen ssh -t "${SYSTEM}" 'tmux attach || tmux new' || ssh "${SYSTEM}" 226 } 227 228 # sets terminal title 229 # useful for unhide (~/.interrobangrc:39) 230 title() { 231 printf "\033]2;${1}\007" 232 } 233 234 # read markdown files like manpages 235 md() { 236 pandoc -s -f markdown -t man "$*" | man -l - 237 } 238 239 # read webpage as manpage 240 webman() { 241 curl -L "$@" | pandoc -s -f html -t man | man -l - 242 } 243 244 # read anything as manpage 245 nam() { 246 pandoc -s -t man "$*" | man -l - 247 } 248 249 mkcd() { 250 mkdir -p "$1" && cd "$1" 251 } 252 253 t() { 254 S=$# 255 [[ $S -eq 0 ]] || S=▒ 256 [ ! -f /tmp/tmux.lock ] && { 257 /usr/bin/tmuxp load ~/.config/tmux/main.yaml && \ 258 touch /tmp/tmux.lock 259 } || \ 260 tmux new-session -A -s "$S" 261 tmux set-environment LC_ALL 'en_US.UTF-8' 262 tmux set-environment LANG 'en_US.UTF-8' 263 } 264 265 :q!() { 266 [[ -v SSH_TTY ]] && echo dumpshock || { 267 ping -q -c1 pigley >/dev/null 2>&1 && { 268 echo -e "${red}lab still online${reset}" 269 vared -p 'shutdown? [Y/n]: ' -c sdwn 270 case ${sdwn} in 271 y|Y) lab down ;; 272 n) ;; 273 *) lab down ;; 274 esac 275 } || echo -e "${green}lab offline${reset}" 276 rm -f /tmp/tmux.lock 277 sudo halt -p 278 } 279 }