config/shell: make some aliases safer & add yay functions

This commit is contained in:
xerus2000 2020-11-14 02:26:30 +01:00
parent dda50a70cc
commit a5063e47e9
2 changed files with 19 additions and 6 deletions

View File

@ -1,13 +1,23 @@
which pacman >/dev/null || return 0
# Arch aliases
alias pac='sudo pacman'
alias pac='noglob sudo pacman'
alias pacs='pac -Syu --needed'
alias pacr='pac -R'
alias yays='yay -S --needed'
alias yayr='yay -R'
alias yays='noglob yay -S --needed'
alias yayr='noglob yay -R'
yzf() {
query=$(test "$1" = "Q" && echo " -l")
pos=$(test "$query" && echo 1 || echo 2)
yay --color always -$1$2 | sed "s/ /\t/g" | fzf --history=/var/tmp/fzf-history-yay --preview "echo {} | cut -f$pos | xargs yay --color always -$1 -i $query" | cut -f$pos
}
yas() {
pkg=$(yay -Pc | cut -d' ' -f1 | fzf --preview 'yay -Si {}')
pkg=$(yzf S l)
test "$pkg" && echo "Install $pkg..." && yay -S "$pkg"
}
yar() {
pkg=$(yzf Q)
test "$pkg" && echo "Removing $pkg..." && yay -R "$pkg"
}

View File

@ -84,11 +84,12 @@ t() {
alias tw='timew'
twsm() { timew summary $(date --date="Monday $1 week ago" -I) to tomorrow :ids ${@:2} }
alias twtest='( TIMEWARRIORDB=/tmp/timewarriordb && rm -rf ${TIMEWARRIORDB} && mkdir -p ${TIMEWARRIORDB}/data && :> ${TIMEWARRIORDB}/timewarrior.cfg && $SHELL )'
alias twtest='( TIMEWARRIORDB=/tmp/timewarriordb && mv ${TIMEWARRIORDB} /tmp/twdb && mkdir -p ${TIMEWARRIORDB}/data && :> ${TIMEWARRIORDB}/timewarrior.cfg && $SHELL )'
# Quick shortcuts
alias c='clear'
alias v='editright'
alias rm='rm -d'
alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G'
alias lar='last | tac'
@ -121,7 +122,9 @@ rpl() {
# Recover stray swap files from neovim
alias vrec="ls $XDG_DATA_HOME/nvim/swap | sed 's/\%/\//g' | sed 's|\(.*\)\..*|\1|' | head -1 | xargs -r nvim"
alias vrecd="ls $XDG_DATA_HOME/nvim/swap | head -1 | xargs -r rm"
alias vrecd="ls $XDG_DATA_HOME/nvim/swap | head -1 | xargs -r -i mv {} /tmp"
unv() { strings $1 | sed 's/5$//' | dedup }
# Applications
alias dict="(builtin cd $XDG_DATA_HOME/dictcc && rlwrap perl dictcc-helper.pl)"