From 0c17ae828054c20c12296c189ff00d2573afab69 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 27 May 2025 17:00:35 +0200 Subject: [PATCH] *: Use xargs instead of `while read` one-line loops --- .config/zsh/autoload/git/git-ssync | 9 ++------- .local/bin/shcwd | 8 ++------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.config/zsh/autoload/git/git-ssync b/.config/zsh/autoload/git/git-ssync index 3a0d4e4..d3946a6 100755 --- a/.config/zsh/autoload/git/git-ssync +++ b/.config/zsh/autoload/git/git-ssync @@ -14,13 +14,8 @@ if [[ "$1" == "--new" ]]; then grep path .gitmodules \ | cut -d= -f2 \ | sed 's/^\s*//' \ - | while read -r line; do - # keep only empty ones - find "$line" -maxdepth 0 -empty - done \ - | while read -r line; do - git submodule update --init --recursive -- "$line" - done + | xargs -I'{}' find '{}' -maxdepth 0 -empty \ + | xargs -L1 git submodule update --init --recursive -- else git submodule update --init --recursive fi diff --git a/.local/bin/shcwd b/.local/bin/shcwd index 6bda419..20e1034 100755 --- a/.local/bin/shcwd +++ b/.local/bin/shcwd @@ -7,15 +7,11 @@ # # pgrep --full "^($TERMINAL|tmux)( |$)" \ # | cut -d' ' -f1 \ -# | while read -r line; do -# pgrep -P "$line" -# done \ +# | xargs -n1 pgrep -P \ # NOTE: when using the full path not all shell instances are matched pgrep "$(basename $SHELL)" \ | cut -d' ' -f1 \ - | while read -r line; do - pwdx "$line" 2>/dev/null - done \ + | xargs pwdx 2>/dev/null \ | cut -d' ' -f2- \ | sort -ur