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