Skip to content

Commit

Permalink
cleanup dotfile and switch bash->zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
kpa28-git committed Dec 21, 2020
1 parent 0b72935 commit 8e9bd52
Show file tree
Hide file tree
Showing 21 changed files with 398 additions and 240 deletions.
46 changes: 0 additions & 46 deletions .bashrc

This file was deleted.

1 change: 1 addition & 0 deletions .bashrc
5 changes: 3 additions & 2 deletions .config/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# Whitelist:
!/alacritty/**
!/alias/**
!/bash/**
!/bspwm/**
!/dunst/**
!/cargo/**
Expand All @@ -25,13 +27,12 @@
!/polybar/**
!/pylint/**
!/qutebrowser/**
!/readline/**
!/redshift/**
!/rofi/**
!/sxhkd/**
!/tmux/**
!/zathura/**
!aliasrc
!/zsh/**
!mimeapps.list
!README.md
!.gitignore
2 changes: 2 additions & 0 deletions .config/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Config Files for programs.

Cross platform aliases in `alias` directory.

Programs with significant configuration:
* bspwm (wm)
* i3 (wm)
Expand Down
5 changes: 5 additions & 0 deletions .config/alias/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Alias
Crossplatform shell aliases for linux and bsd, pick and choose which ones to load in your shell profile file.

## Requirements
The `posix.sh` file must be loaded first. All other alias files are optional and can be loaded in any order.
3 changes: 3 additions & 0 deletions .config/alias/alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# alpine linux aliases

27 changes: 27 additions & 0 deletions .config/alias/arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# arch linux aliases

alias y="yay" \
yg="y -Qs | grep" \
yq="y -Qi" \
yps="y -Ps" \
yys="y -Syu" \
yysp="y -Syu && poweroff" \
yysr="y -Syu && reboot" \
yyf="y -Syyu" \
yrm="y -Rsn" \
yls="y -Ql" \
ycl="y -Yc && paccache -r" \
yrmlck="sudo rm '/var/lib/pacman/db.lck'" \
pacls="pacman -Qett --color=always" \
pacwhen="expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort" \
pacmirrup="sudo reflector --country 'United States' --latest 200 --age 24 --sort rate --save /etc/pacman.d/mirrorlist && rm -f /etc/pacman.d/mirrorlist.pacnew";

alias ifck="informant check" \
ifls="informant list" \
ifrd="informant read" \
ifi="ifrd \"\$(ifls | fzf | sed 's/:.*//')\"";

alias lsfont="fc-list" \
lsfontfam="lsfont : family";

35 changes: 35 additions & 0 deletions .config/alias/custom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh
# custom aliases and functions go here

# search aliases
alias lspaths="fd -HI --ignore-file \"\$HOME\"/.config/fd/ignore_file" \
s="lspaths | fzf --reverse --info=inline --preview='pistol {}'" \
se="\$EDITOR \"\$(s --header='Edit File')\"" \
sd="moveto \"\$(s --header='Search Directory')\"" \
so="\$OPENER \"\$(s --header='Open File')\"" \
sr="\$READER \"\$(fd -I -t 'f' '.' \"\$READING\" | sed \"s|\$READING\/||\" | fzf --reverse --info=inline --preview=\"pistol \$READING/{}\" --header='Select Reading' | sed \"s|^|\$READING\/|\")\"";

# history aliases
alias h="history" \
hg="h | grep" \
hs="h | fzf --tac --info=inline --header='Search Command' | sed 's/^[0-9]*\s*//g'" \
hi="xdotool type --delay 0 \"\$(hs)\" && clear";

moveto() {
FILEPATH=$([ -d "$1" ] && echo "$1" || dirname "$1");
cd "$FILEPATH" || return;
}
sg() {
RES="$(s --header='Grep File')";
grep "$1" "$RES";
}
tunder() {
for i in *' '*; do mv "$i" `echo $i | sed -e 's/ /_/g'`; done
}

#command -v nvim >/dev/null && alias vim="nvim" vimdiff="nvim -d" # Alias neovim as vim if present.
#vf() {
# fzf | xargs -r -I % $EDITOR % ;
#}
#shdl() { curl -O $(curl -s http://sci-hub.tw/"$@" | grep location.href | grep -o http.*pdf) ;}
#sv() { vcopy "$(du -a ~/.local/bin/* ~/.config/* | awk '{print $2}' | fzf)" ;}
3 changes: 3 additions & 0 deletions .config/alias/freebsd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# free bsd aliases

11 changes: 11 additions & 0 deletions .config/alias/load-aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# load posix shell aliases

[ -f "$ALIASDIR/posix.sh" ] && . "$ALIASDIR/posix.sh"
if posix_str_isin "arch" "$KERNEL_RELEASE" ; then
[ -f "$ALIASDIR/arch.sh" ] && . "$ALIASDIR/arch.sh"
[ -f "$ALIASDIR/systemd.sh" ] && . "$ALIASDIR/systemd.sh"
fi;
[ -f "$ALIASDIR/programs.sh" ] && . "$ALIASDIR/programs.sh"
[ -f "$ALIASDIR/custom.sh" ] && . "$ALIASDIR/custom.sh"

2 changes: 2 additions & 0 deletions .config/alias/openrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh

52 changes: 52 additions & 0 deletions .config/alias/posix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh
# basic aliases and utilities for linux, bsd, and posix systems

# replace utils with rust alternatives
alias l="exa -lah --git --color=auto --group-directories-first" \
ls="exa -h --color=auto --group-directories-first" \
grep="rg" \
cat="bat --theme=zenburn" \
find="fd -HI --ignore-file \"\$HOME\"/.config/fd/ignore_file";

# basic
alias f="\$FILE" \
e="\$EDITOR" \
v="\$EDITOR" \
c="clear" \
i="htop -t" \
diff="diff --color=auto" \
lg="l | grep" \
mkd="mkdir -pv" \
manp="man 1p" \
duse="du -chH | sort -h" \
lb="lsblk -o MODE,TYPE,HOTPLUG,FSTYPE,FSVER,NAME,MOUNTPOINT,LABEL,STATE,FSUSE%,FSUSED,FSSIZE,SIZE,MODEL,PARTUUID" \
kafter="timeout -sTERM" \
sdn="sudo shutdown -h now" \
lap="ps -u" \
kap="killall" \
mimetype="file --mime-type" \
xdgtype="xdg-mime query filetype" \
xdgdefault="xdg-mime query default" \
xorgfocusinfo="xprop -id \`xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print \$NF}'\`" \
today="date '+%Y-%m-%d'" \
wget="curl -O" \
myports="sudo netstat -tulpn" \
watch2="watch -n 2 " \
lamp="ps -u \`whoami\`" \
kamp="kap -u \`whoami\`";

# networking
alias lptl="sudo lsof -i -P -n | grep LISTEN" \
myip="curl -q ifconfig.co";

# basic posix utils

posix_str_isin() {
# usage: posix_str_isin "b" "aba" (https://stackoverflow.com/questions/55425293/bash-compare-a-command-output-to-string)
[ -z "${2##*$1*}" ] && { [ -z "$1" ] || [ -n "$2" ] ;}
}

posix_isint() {
# usage: posix_isint "number" (https://github.com/dylanaraps/pure-sh-bible#check-if-a-number-is-an-integer)
printf %d "$1" >/dev/null 2>&1;
}
75 changes: 75 additions & 0 deletions .config/alias/programs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/sh
# program and web api aliases

# misc programs
alias mpv="mpv --input-ipc-server=/tmp/mpvsoc\$(date +%s)" \
x="sxiv -ft *" \
ytd="youtube-dl --add-metadata -i -o '\$HOME/Downloads/%(upload_date)s-%(title)s.%(ext)s'" \
ytda="youtube-dl --add-metadata -i -x -f 'bestaudio/best' -o '\$HOME/Music/%(upload_date)s-%(title)s.%(ext)s'" \
ffmpeg="ffmpeg -hide_banner" \
dt="dust" \
dt3="dt -d 3" \
grex="grex -r" \
ccat="highlight --out-format=ansi" \
appsync="rsync -avxP" \
mirsync="rsync -avxP --delete" \
shck="shellcheck" \
tmr="peaclock --config-dir=\"\$XDG_CONFIG_HOME/peaclock\" --config=\"\$(fd '[^\.gitignore]' --regex -t 'f' -d 1 \"$XDG_CONFIG_HOME/peaclock\" | fzf --select-1)\"" \
viewdoc="fzf --sync | pandoc -f docx -t pdf | zathura -" \
vd="vidir" \
pwi="sudo powertop" \
nv="nvidia-smi" \
nvw="watch2 nv" \
nvi="nvtop" \
jup="jupyter notebook --ip=127.0.0.1 --port=8888";

alias g="git" \
gst="g status" \
gsb="gst -sb" \
gss="gst -s" \
gd="g diff --color" \
gds="gd \$(gss | awk '{print \$NF}' | fzf --reverse --info=inline --preview='git diff --color {}' --header 'git diff file')" \
gdc="gd --cached" \
gdcs="gd --cached \$(gss | awk '{print \$NF}' | fzf --reverse --info=inline --preview='git diff --color --cached {}' --header 'git diff cached (staged) file changes')" \
gdh="gd HEAD" \
gdhs="gd HEAD \$(gss | awk '{print \$NF}' | fzf --reverse --info=inline --preview='git diff --color HEAD {}' --header 'git diff changes compared to HEAD')" \
gc="g clone" \
gls="g log" \
gl="g pull" \
gp="g push" \
gulp="g submodule foreach git pull origin master" \
ga="g add" \
gas="ga \$(gss | awk '{print \$NF}' | fzf --multi --reverse --info=inline --preview='git diff --color {}' --header 'git add files, use shift+Tab to multiselect')" \
gr="g remote" \
grm="g rm" \
gcsmg="g commit -m" \
gcmsg="g commit -m" \
gcmsga="g commit --amend" \
gua="gr | xargs -L1 git push --all" \
glp="gl && gp";

alias cg="conda list | grep" \
cq="conda info" \
cls="conda list" \
car="conda activate" \
cdr="conda deactivate" \
cup="conda update conda pip" \
cua="conda update --all" \
crm="conda remove" \
ccl="conda clean --yes --all";

alias tdd="trash-put" \
tls="trash-list | \$PAGER" \
tre="trash-restore" \
trm="trash-rm \"\$(trash-list | fzf --reverse --info=inline --header='Delete File' | awk '{print \$NF}')\"" \
tem="trash-empty";

alias coins="curl -s rate.sx/?q" \
eth1="curl -s rate.sx/eth@1w?q" \
eth2="curl -s rate.sx/eth@2w?q" \
eth4="curl -s rate.sx/eth@4w?q" \
eth8="curl -s rate.sx/eth@8w?q" \
eth24="curl -s rate.sx/eth@24w?q" \
eth52="curl -s rate.sx/eth@52w?q" \
btc2="curl -s rate.sx/btc@2w?q";

2 changes: 2 additions & 0 deletions .config/alias/runit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh

10 changes: 10 additions & 0 deletions .config/alias/systemd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# systemd aliases

alias sstart="sudo systemctl start" \
sstop="sudo systemctl stop" \
senable="sudo systemctl enable" \
sdisable="sudo systemctl disable" \
srestart="sudo systemctl restart" \
sstatus="systemctl status";

3 changes: 3 additions & 0 deletions .config/alias/void.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# void linux aliases

Loading

0 comments on commit 8e9bd52

Please sign in to comment.