From a5063e47e9fb81e9e243f593e08558d1ac8ee922 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Sat, 14 Nov 2020 02:26:30 +0100 Subject: [PATCH] config/shell: make some aliases safer & add yay functions --- .config/shell/arch | 18 ++++++++++++++---- .config/shell/functions | 7 +++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.config/shell/arch b/.config/shell/arch index a796b35..6b9669f 100644 --- a/.config/shell/arch +++ b/.config/shell/arch @@ -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" +} diff --git a/.config/shell/functions b/.config/shell/functions index 209af06..a5d8c1c 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -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)"