config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit be3254a291c54eb6b7ebf333650920175ad4afaa
parent 83b041a65942a8b6db3cfefa35dba784ff747126
Author: jacob@thinkpad <jacobouno@protonmail.com>
Date:   Tue, 28 Apr 2020 14:40:25 -0700

Removing messy or unused and documenting everything.

prettier sections, ordering, and other general formatting

apropriately further seperate OpenBSD and linux/archlinux aliases

a dependant structure to some aliases that rely on previous alias definitions

Diffstat:
Maliases/.aliases | 134+++++++++++++++++++++++++++++++++++++++++++------------------------------------
1 file changed, 73 insertions(+), 61 deletions(-)

diff --git a/aliases/.aliases b/aliases/.aliases @@ -1,30 +1,66 @@ -# vim filetype=sh +#vim: filetype=sh +# Jacob Edwards +# created: Feb 10, 2020, updated: Apr 28, 2020 +# shell aliases and functions, specificaly for archlinux and OpenBSD + + +#---------# +# aliases # +#---------# + + # source private aliases -[ -f "$HOME/.aliases-private" ] && . "$HOME/.aliases-private" +if [ -f "$HOME/.aliases-private" ]; then + . "$HOME/.aliases-private" +fi + if [ $(uname) = "OpenBSD" ]; then alias xenodm="doas xenodm" - alias pa="doas pkg_add" + # pkg + alias pkg_add="doas /usr/sbin/pkg_add -xV" + alias pa="pkg_add" alias pi="pkg_info" + alias pq="pi -Q" elif [ $(uname) = "Linux" ]; then - alias pacman="pacman-wrapper" - alias pa="pacman" - alias startx="startx ~/.xinitrc" - alias sudo="sudo -E " + alias pacman="pa" alias sys="systemctl" - alias suspend="systemctl suspend" + alias suspend="sys suspend" fi -alias man="man " +# superuser alias doas="doas " +alias sudo="sudo -E " + +# expand aliases +alias man="man " + +# use extended regex +alias sed="sed -E" alias grep="egrep" + +# simple shorthand alias meta="exiftool" + +# disable default mpv bindings alias mpv="mpv --no-input-default-bindings" + +# supress verbosity and unconsequential errors (i.e. "plugin X invalid" or "reading config from /home/.......") alias ncmpcpp="ncmpcpp -q" + +# kill only exact procces names alias pkill="pkill -x" -alias sed="sed -E" -alias tmux="tmux -u" + +# list what port sshd listens on +alias ssh-port="grep -Ei '^port' /etc/ssh/sshd_config || echo 'port 22'" + +# display current date and time in filesystem friendly format +alias now="date +%Y%m%d-%H%M%S" + +# locations +alias ds="cd ~/src/suckless/" +alias dn="cd $NOTES" # 1 char alias l="$PAGER" @@ -34,53 +70,39 @@ alias n="nvim" alias v="vim" # git -alias gd="git diff --cached" -alias ga="git add" -alias gc="git commit" -alias gP="git push" -alias gp="git pull" -alias gr="git remote" - -# locations -alias s="cd ~/src/suckless/" -alias cn="cd $NOTES" - -# short scripts etc -alias ssh-port="grep -Ei '^port' /etc/ssh/sshd_config || echo 'port 22'" - -# example usage: cp file file.$(now) -alias now="date +%Y%m%d-%H%M%S" - - - -## one-line functions -# delay execution of command by input * 60 seconds (must quote command) -t() { sleep $(calc -d "$1" \* 60); $2 ;} - -# start tmux automaticly on ssh -ssh() { /usr/bin/ssh -t "$@" "tmux a || tmux new" ;} +alias g="git" +alias gd="g diff" +alias ga="g add" +alias gc="g commit" +alias gP="g push" +alias gp="g pull" +alias gl="g log" + + +#-----------# +# functions # +#-----------# + +# start tmux if no other command is specified +ssh() { + if [ -z $2 ]; then + /usr/bin/ssh -t "$@" "tmux a || tmux new" + else + /usr/bin/ssh "$@" + fi +} -## multi-line functions # get working directory wd() { local home="$(printf $HOME | sed -E 's/\//\\\//g')" pwd | sed "s/$home/~/g" } -# try connecting to host -is_up() { - if [ "$(ping -c 1 -W 1.2 "$1" | tail -n 2 | head -n 1 | cut -d ',' -f 2 | awk '{print $1}')" -ne 0 ]; then - printf "$1 is up.\n" - else - printf "$1 is down.\n" - fi -} # open note for the day daily() { time="$(date +%H%M)" - # counts as the previous day until six if ! [ "$time" -gt 0 -a "$time" -lt 600 ]; then date="$(date +%Y/%m/%d)" @@ -104,22 +126,26 @@ daily() { note "daily/$date" } + # get frame in given video at given time snap() { ffmpeg -ss $2 -i $1 -loglevel 8 -frames:v 1 $3 } + # convert video to grayscale grayscale() { ffmpeg -i $1 -vf format=gray $2 } + # get window name wm_name() { id="$(xprop -root | grep '_NET_ACTIVE_WINDOW' -m1 | awk -F '# ' '{print $2}')" xprop -id "$id" | grep 'WM_CLASS' -m1 | cut -d '"' -f 2 } + # get window class wm_class() { id="$(xprop -root | grep '_NET_ACTIVE_WINDOW' -m1 | awk -F '# ' '{print $2}')" @@ -127,24 +153,15 @@ wm_class() { } -## history functions # history search hs() { if [ -n "$2"]; then - fc -n -l 0 | grep "$1" | tail + fc -n -l 0 | grep "$1" | tail -n 20 else fc -n -l 0 | grep "$1" | tail -n "$2" fi } -# repeat -#r() { -# if [ -z "$1" ]; then -# fc -s -# else -# eval $(hs "$1" 1) -# fi -#} # repeat edit re() { @@ -155,8 +172,3 @@ re() { fc -e "$EDITOR" $index fi } - -# list repositories on git server -gf() { - ssh git ls | grep "$@" -}