From 0988225c090ca167ae9af3818a25b87128ab3f6f Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 13 Oct 2022 21:56:23 +0200 Subject: [PATCH] config/shell: function adjustments --- .config/shell/browse | 2 ++ .config/shell/functions | 21 +++++++++++++++------ .config/shell/graphical | 8 -------- .local/bin/scripts/xo | 7 +++++++ 4 files changed, 24 insertions(+), 14 deletions(-) create mode 100755 .local/bin/scripts/xo diff --git a/.config/shell/browse b/.config/shell/browse index 9629f6e..a9e3180 100644 --- a/.config/shell/browse +++ b/.config/shell/browse @@ -1,5 +1,7 @@ # Utilities for file system navigation +alias watchdir='watch -c -n 1 exa -l --icons' + # Useful when the current directory was recreated alias recd='cd $PWD' # [c]hange [d]irectory [e]xisting - cd into the first existing directory diff --git a/.config/shell/functions b/.config/shell/functions index 3deb7d2..7b0d554 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -244,11 +244,15 @@ del() { } u() { - if test "$(stat /etc/pacman.d/mirrorlist --printf=%y | cut -d'-' -f1-2)" != "$(date +%Y-%m)" - then command -v pacman-mirrors >/dev/null && - sudo pacman-mirrors --geoip || - sudo touch /etc/pacman.d/mirrorlist - if command -v pacman >/dev/null; then + # Line below handy for users of netkeeper + ping example.com -c 1 -w 2 >/dev/null && sudo nft list ruleset | grep -1 outall | grep -q 'meta hour' || echo sysupgrade | netkeeper 30 2>/dev/null + if command -v pacman >/dev/null; then + if test "$(stat /etc/pacman.d/mirrorlist --printf=%y | cut -d'-' -f1-2)" != "$(date +%Y-%m)" + then + if command -v pacman-mirrors >/dev/null + then sudo pacman-mirrors --geoip + else sudo touch /etc/pacman.d/mirrorlist + fi sudo pacman -Syy --needed base gnupg archlinux-keyring sudo pacman-key --populate sudo pacman-key --refresh-keys @@ -373,7 +377,12 @@ dic() { } #fzf --tiebreak=length --bind='alt-bspace:clear-query' alias dict="rlwrap rdictcc --directory $DICT" -alias dict_update="dict -i $DICT/dict.txt" +dict_update() { + local dictfile="$DICT/dict.txt" + test $# -gt 0 && mv -v $1 "$dictfile" + echo "Reading in $dictfile..." + unbuffer rdictcc --directory $DICT -i "$dictfile" | rewrite +} npm-reinstall() { rm -rf $TMPDIR/react-* diff --git a/.config/shell/graphical b/.config/shell/graphical index e546c5e..f8355ad 100644 --- a/.config/shell/graphical +++ b/.config/shell/graphical @@ -2,14 +2,6 @@ command -v notify-send >/dev/null && alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(echo "$history[$HISTCMD]" | sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' -xo() { - while test $# -gt 0; do - xdg-open "$1" - shift - done -} - - if which jrnl >/dev/null; then alias j='jrnl' jn() { jrnl -to today "$@" | less +G; } diff --git a/.local/bin/scripts/xo b/.local/bin/scripts/xo new file mode 100755 index 0000000..08ecab4 --- /dev/null +++ b/.local/bin/scripts/xo @@ -0,0 +1,7 @@ +#!/bin/sh +# xdg-open all given files +# TODO handle .desktop-files with gtk-launch/dex/kioclient exec, add selector from xdg-mime-file +while test $# -gt 0; do + xdg-open "$1" + shift +done