commit 517be796d3355d7dab8de94209963c04a40cd50a
parent ab6cbd2d48f2aacb84b4dcbae9fd702a24e093e8
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Sat, 18 Jul 2020 21:55:31 -0700
Add, remove, and sort aliases and functions
remove Linux, za, muf, python/py, dbf, webfilter, meta, and sp aliases
capitalize description and section comments
add more sections
add self function to re execute current process (i.e. your shell)
replace now alias with a more powerful function
refine lk function with brace expansion
rename mkf (mkdir -p dirname then edit) to ff
Diffstat:
| M | aliases/.aliases | | | 179 | ++++++++++++++++++++++++++++++++++++++----------------------------------------- |
1 file changed, 87 insertions(+), 92 deletions(-)
diff --git a/aliases/.aliases b/aliases/.aliases
@@ -2,75 +2,48 @@
# Jacob Edwards, created: 2020/02/10
# shell functions for unix systems
-alias doas="doas -- "
-
if [ -f "$HOME/.aliases-private" ]; then
. "$HOME/.aliases-private"
fi
-## Defining package manager alias specification:
-# pa; install package
-# pu; upgrade installed packages
-# pd; uninstall package
-# ps; query ALL packages
-# pS; verbose query ALL packages
-# pq; query installed packages
-# pQ; verbose query installed packages
-
-if [ `uname` = "OpenBSD" ]; then
- alias xenodm="doas xenodm"
- alias pkg_add="pkg_add -xV"
-
- # pkg
- # NOTE: i'll update these when I have access to my openbsd machine again.
- alias pa="doas pkg_add"
- alias pu="doas pkg_add -u"
- alias pd="doas pkg_delete"
- alias ps="pkg_info -Q"
- alias pS="pkg_info -cQ"
- alias pq="pkg_info"
- alias pQ="pkg_info -c"
-elif [ -x /usr/bin/pacman ]; then
- alias sys="systemctl"
- alias cc="gcc -fdiagnostics-color=never"
-
- # pkg
- alias pa="doas pacman -Syu"
- alias pu="pa"
- alias pd="doas pacman -Rs"
- alias pq="pacman -Qs"
- alias pQ="pacman -Qi"
- alias ps="pacman -Ss"
- alias pS="pacman -Si"
-fi
-
-# add arguments/change name
-alias sp="command ps"
-alias mstat="command ps -eo pmem,rss,args --sort pmem | grep -v '^[[:space:]]0.0'"
+# The trailing space expands aliases
+alias doas="doas -- "
alias man="man "
+
+# Multiple file options opened as tabs
alias nvim="nvim -p"
alias vim="vim -p"
+
+# Use extended regular expressions
alias sed="sed -E"
alias grep="egrep"
-alias meta="exiftool"
-alias mpv="mpv --no-input-default-bindings"
-alias pkill="pkill -x"
-alias col="column -ts"
-alias now="date +%Y%m%d-%H%M%S"
+
+# Clipboard
alias grab="xclip -selection clipboard"
alias push="xclip -selection clipboard -out"
-alias la="ls -A"
-# change name
-alias za="zathura"
-alias muf="mupdf"
+# Very short
alias f="$EDITOR"
alias l="$PAGER"
-alias dbf="locate"
alias g="grep"
alias ic="ifconfig"
-alias python="python3"
-alias py="python"
+
+# Question to the non-existent viewers of this file. is there an rss aggregator
+# for text that simply formats and prints to terminal, possibly with some
+# selection options like feed and article?
+alias nb="newsboat"
+
+# Package managment (openbsd)
+# pa: install, pu: upgrade installed, pd: uninstall, pqq: query all, pQQ:
+# verbose query all, pq: query installed, pQ: verbose query installed.
+alias pkg_add="pkg_add -xV"
+alias pa="doas pkg_add"
+alias pu="doas pkg_add -u"
+alias pd="doas pkg_delete"
+alias pqq="pkg_info -Q"
+alias pQQ="pkg_info -cQ"
+alias pq="pkg_info"
+alias pQ="pkg_info -c"
# git
alias gd="git diff"
@@ -84,7 +57,6 @@ alias gdc="gd --cached"
# webq (searx parsing script)
wq() { webq $@ | column -ts\~ ;}
wQ() { webq "`eval echo $@`" | column -ts\~ ;}
-webfilter() { grep -Eiv "(instagram|twitter|youtube|google|top [0-9]+|can'?t live with|you won'?t believe|of [0-9]+|of all time)" ;}
# cargo/rust
alias rs="cargo"
@@ -107,32 +79,56 @@ alias ml="m playlist"
alias mL="m lsplaylist"
alias mq="m search any"
-# get configuration from mpd.conf (oneline options only)
-mconf() { grep $1 $XDG_CONFIG_HOME/mpd/mpd.conf | sed -E 's/.*"(.*)\"/\1/g' ;}
-
-# add current song to playlist
-mato() { mpc current -f "%file%" >> $(eval echo $(mconf playlist_directory))/$@.m3u ;}
+# Get mpd configuration (oneline options only)
+mpd-config() { grep $1 $XDG_CONFIG_HOME/mpd/mpd.conf | sed -E 's/.*"(.*)\"/\1/g' ;}
-# cd into mpc music dir
-mcd() { cd "$(eval echo `mconf music_directory`)" ;}
+# Add current song to playlist
+mato() { mpc current -f "%file%" >> $(eval echo $(mpd-config playlist_directory))/$@.m3u ;}
-# replace playlist with current
+# Replace playlist with current
mrepl() {
- dir="$(eval echo $(mconf playlist_directory))"
+ dir="$(eval echo $(mpd-config playlist_directory))"
mv -v $dir/$1.m3u $dir/.$1.m3u && mpc save $1
}
-# make directories leading up to filename then edit that
-mkf() {
+# random
+alias mstat="command ps -eo pmem,rss,args --sort pmem | grep -v '^[[:space:]]0.0'"
+alias mpv="mpv --no-input-default-bindings"
+alias pkill="pkill -x"
+alias col="column -t"
+alias la="ls -A"
+
+
+# Search all history for `regex`
+hs() { fc -nl 0 | egrep "$1" ;}
+
+# List podcast names
+lsrpa() { rpa -ni0 | cut -d':' -f1 ;}
+
+# Unset proxy env variables
+nproxy() { unset ALL_PROXY; unset HTTP_PROXY ;}
+
+# Infinite loop that runs every time you hit enter
+loop() { while true; do read args || break; eval $@ $args; done ;}
+
+# Search sxhkd keybinds
+lk() { egrep "${@-.}" -iC3 $XDG_CONFIG_HOME/sxhkd/sxhkdrc ;}
+
+# Pipe du into sort -h
+ds() { du -sh $@ | sort -h ;}
+
+# Redo last command (I frequently type k+enter before escape in vi mode)
+k() { fc -s ;}
+
+# Make directories leading up to filename then edit that
+ff() {
mkdir -p `dirname $1`
f $1
}
-# get working directory HOME with shorthand
-wd() { pwd | sed "s|$HOME|~|g" ;}
-
-# open note for today
-daily() {
+# Open note for today
+daily()
+{
time="$(date +%H%M)"
if [ "$time" -gt 0 -a "$time" -lt 600 ]; then
date=$(perl -e "use DateTime; print DateTime->today(time_zone => 'local')->add(days => -1)->strftime('%Y/%m/%d');")
@@ -145,29 +141,28 @@ daily() {
else
echo "\n\n$time" >> "$NOTES/daily/$date"
fi
- mkf "$NOTES/daily/$date"
+ ff "$NOTES/daily/$date"
}
-# search all history for `regex`
-hs() { fc -nl 0 | egrep "$1" ;}
-
-# list podcast names
-lsrpa() { rpa -ni0 | cut -d':' -f1 ;}
-
-# unset proxy env variables
-nproxy() { unset ALL_PROXY; unset HTTP_PROXY ;}
-
-# infinite loop that runs every time you hit enter
-loop() { while true; do read args || break; eval $@ $args; done ;}
-
-# search sxhkd keybinds
-lk() {
- # NOTE: .? is to list everything should user omit any arguments.
- egrep ".?$@" -iC3 $XDG_CONFIG_HOME/sxhkd/sxhkdrc
+# Print the current date, time, or date and time to stdout.
+now()
+{
+ local date="%Y%m%d"
+ local time="%H%M%S"
+ if [ -z $1 ]; then
+ now full
+ else
+ case $1 in
+ f|full) date +$date-$time;;
+ d|date) date +$date;;
+ t|time) date +$time;;
+ *) echo "error: undefined" 1>&2; return 1;;
+ esac
+ fi
}
-# pipe du into sort -h
-ds() { du -h $@ | sort -h ;}
-
-# redo last command (I frequently type k+enter before escape in vi mode)
-k() { fc -s ;}
+# Reinitialize shell
+self()
+{
+ exec $0
+}