From 64d9d82afbe9fcdabc9e4b9c5f02bf12c093645c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 20:42:43 +0200 Subject: checkpoint --- bin/extra/trl | 33 +++--------------- bin/extra/ytplay | 7 +++- bin/guiscripts/dmfm | 22 ++++++------ bin/menuscripts/mmedia | 91 ++++++++++++++++++++++++++++---------------------- bin/menuscripts/tsh | 6 ++-- 5 files changed, 76 insertions(+), 83 deletions(-) (limited to 'bin') diff --git a/bin/extra/trl b/bin/extra/trl index 55d65ee..957d0fb 100755 --- a/bin/extra/trl +++ b/bin/extra/trl @@ -5,33 +5,7 @@ # returns available languages languages () { - cat <<-EOF - arabic - dutch - french - german - polish - english - portuguese - spanish - romanian - hebrew - swedish - italian - turkish - japanese - ukrainian - korean - chinese - czech - hungarian - danish - persian - greek - slovak - hindi - thai - EOF + printf 'arabic\nchinese\nczech\ndanish\ndutch\nenglish\nfrench\ngerman\ngreek\nhebrew\nhindi\nhungarian\nitalian\njapanese\nkorean\npersian\npolish\nportuguese\nromanian\nslovak\nspanish\nswedish\nthai\nturkish\nukrainian\n' } if [ -z "${word:=$1}" ] @@ -47,11 +21,12 @@ primary="$(languages | fzf --prompt="from:")" secondary="$(languages | fzf --prompt="to:")" [ "$secondary" ] || exit 1 -curl -s "https://context.reverso.net/translation/$primary-$secondary/$word" \ +# url="https://www.reverso.net/text-translation#sl=$primary&tl=$secondary&text=$word" +url="https://context.reverso.net/translation/$primary-$secondary/$word" +curl -s "$url" \ --compressed \ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \ - -H 'Accept-Language: en-US,en;q=0.5' \ -H 'Accept-Encoding: gzip, deflate, br' | pup 'a.link_highlighted em text{}' | sed 's/.*/\L&/' | diff --git a/bin/extra/ytplay b/bin/extra/ytplay index 5243364..4b23732 100755 --- a/bin/extra/ytplay +++ b/bin/extra/ytplay @@ -1,4 +1,9 @@ #!/bin/sh url="$(ytlink)" herbe "playing: $url" & -yt-dlp -o - "$url" | mpv - +yt-dlp "$url" \ + --embed-chapters \ + -f "b" \ + -S "res:1080" \ + -o - | + mpv - diff --git a/bin/guiscripts/dmfm b/bin/guiscripts/dmfm index 9485469..b7a68d2 100755 --- a/bin/guiscripts/dmfm +++ b/bin/guiscripts/dmfm @@ -1,20 +1,20 @@ #!/bin/sh -while true -do - dir="$(printf '%s' "$PWD" | sed "s#^$HOME#\~#;s#\([^/]\)[^/]*/#\1/#g")" - file=$(find . -maxdepth 1 -mindepth 1 -not -name '.*' -printf '%y\t%f\n' | +[ -d "$1" ] && cd "$1" + +while true; do + choice=$(find . -maxdepth 1 -mindepth 1 -not -name '.*' -printf '%y\t%f\n' | sort -k 1 -k 2 | cut -f 2- | - commander -xc -p "$dir") + dmenu -x -c -i -p "$(pwd)") - [ "$file" ] || break - [ ! -e "$file" ] && continue + [ "$choice" ] || break + [ -e "$choice" ] || continue - if [ -d "$file" ] - then - cd "$file" || continue + if [ -d "$choice" ]; then + cd "$choice" || continue else - setsid xdg-open "$PWD/$file" & + setsid xdg-open "$choice" & + exit fi done diff --git a/bin/menuscripts/mmedia b/bin/menuscripts/mmedia index 3141c3b..f4e6e3c 100755 --- a/bin/menuscripts/mmedia +++ b/bin/menuscripts/mmedia @@ -6,52 +6,65 @@ dirs="$HOME/dl" concat_path() { sed "s#^$HOME#\~#;s#\([^/]\)[^/]*/#\1/#g"; } -case "$1" in - "video") - regex='^.\+\.\(webm\|mp4\|mpeg\|mkv\)$' - dirs="$dirs $HOME/vids" - viewer() { $PLAYER "$1"; } ;; - "pdf") - regex='^.\+\.\(pdf\)$' - dirs="$dirs $HOME/docs" - viewer() { $VIEWER "$1"; } ;; - "image") - regex='^.\+\.\(png\|avif\|jpg\)$' - dirs="$dirs $HOME/pics" - viewer() { $IMAGE "$1"; } ;; - "cursus") - regex='^.*/[cC]ursus/index.html$' - dirs="$HOME/docs/school/Vakken" - concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##"; } - viewer() { $BROWSER "$1"; } ;; - "schoolpdf") - regex='^.\+\.\(pdf\)$' - dirs="$HOME/docs/school/Vakken" - concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##;s#/Cursus/viewer/files/#: #"; } - viewer() { $VIEWER "$1"; } ;; - *) - choice="$(cat <<-EOF | dmenu -g 5 -l 1 -c - video - pdf - image - cursus - schoolpdf +case "$1" in +"video") + regex='^.\+\.\(webm\|mp4\|mpeg\|mkv\)$' + dirs="$dirs $HOME/vids" + viewer() { $PLAYER "$1"; } + ;; +"pdf") + regex='^.\+\.\(pdf\)$' + dirs="$dirs $HOME/docs" + viewer() { $VIEWER "$1"; } + ;; +"image") + regex='^.\+\.\(png\|avif\|jpg\)$' + dirs="$dirs $HOME/pics" + viewer() { $IMAGE "$1"; } + ;; +"cursus") + regex='^.*/[cC]ursus/index.html$' + dirs="$HOME/docs/school/Vakken" + concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##"; } + viewer() { $BROWSER "$1"; } + ;; +"schoolpdf") + regex='^.\+\.\(pdf\)$' + dirs="$HOME/docs/school/Vakken" + concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##;s#/Cursus/viewer/files/#: #"; } + viewer() { $VIEWER "$1"; } + ;; +"lecture") + dmfm $HOME/docs/lecture + exit + ;; +*) + choice="$( + cat <<-EOF | dmenu -g 6 -l 1 -c + video + pdf + image + cursus + schoolpdf + lecture EOF - )" - [ "$choice" ] || exit 1 - "$0" "$choice" - exit ;; + )" + [ "$choice" ] || exit 1 + "$0" "$choice" + exit + ;; esac shift [ "$1" ] && dirs="$1" choice="$( - find -L $dirs 2> /dev/null | - grep "$regex" | - sort | tee "$tmp" | - concat_path | - dmenu -px -c -i -l 10 -g 1 -x)" + find -L $dirs 2>/dev/null | + grep -i "$regex" | + sort | tee "$tmp" | + concat_path | + dmenu -px -c -i -l 10 -g 1 -x +)" file="$(sed -n "${choice}p" "$tmp")" [ -r "$file" ] || exit 1 diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index 0c57ee0..72670f2 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -170,8 +170,11 @@ then # Get results rm -f "$results" "$links" + # shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 . "$MODULES_PATH/$module" + get_torrents + [ -f "$results" ] || die "No results." # Save which module was used @@ -180,9 +183,6 @@ else module="$(tail -n 1 "$links")" fi -# acquire get_magnet function -# shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 -getfunctions=1 . "$MODULES_PATH/$module" # select result from "$results" for choice in $(select_result | xargs) -- cgit v1.2.3 From f039e82cac63f24ee7386bb3efd1fc6921d14d12 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 20:45:20 +0200 Subject: checkpoint --- bin/menuscripts/tsh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'bin') diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index 72670f2..19a7373 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -3,34 +3,27 @@ PROG="$(basename "$0")" ## VARIABLES # copy command and deps variable -deps="pup curl $MENUCMD" +deps="pup curl clipp" MODULES_PATH=$HOME/.local/share/tsh module='nyaa.sh' # default module # Files export tmp="/tmp/$PROG" + files="seeds sizes names html tmp_types" # Use export so that these variables can be used inside of modules for file in $files do eval "export $file=$tmp/$file" done + # Files not in $files won't be deleted export results="$tmp/results" export links="$tmp/links" categories="music anime movies shows other software games isos books" -if [ "$WAYLAND_DISPLAY" ] -then - clipp() { wl-copy -n; } - deps="$deps wl-copy" -else - clipp() { xclip -selection clipboard -r; } - deps="$deps xclip" -fi ## FUNCTIONS - help () { >&2 cat <<-EOF @@ -71,10 +64,6 @@ dependencies () [ "${error:-0}" -eq 1 ] && exit 1 } -# shellcheck disable=SC2046 -# (we use word splitting on purpose) -isOnline () { grep -q '1' $(echo /sys/class/net/*/carrier | sed 's#/sys/class/net/lo/carrier ##'); } - # Remove temp files and quit cleanup () { -- cgit v1.2.3 From 6cf892bcb7f444d7941cb70308038193b8d9c602 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 21:01:23 +0200 Subject: checkpoint --- bin/menuscripts/tsh | 250 +++++++++++++++++++++++----------------------------- 1 file changed, 112 insertions(+), 138 deletions(-) (limited to 'bin') diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index 19a7373..0e2b64d 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -3,7 +3,7 @@ PROG="$(basename "$0")" ## VARIABLES # copy command and deps variable -deps="pup curl clipp" +deps="pup curl clipp transmission-cli" MODULES_PATH=$HOME/.local/share/tsh module='nyaa.sh' # default module @@ -13,8 +13,8 @@ export tmp="/tmp/$PROG" files="seeds sizes names html tmp_types" # Use export so that these variables can be used inside of modules -for file in $files -do eval "export $file=$tmp/$file" +for file in $files; do + eval "export $file=$tmp/$file" done # Files not in $files won't be deleted @@ -23,175 +23,149 @@ export links="$tmp/links" categories="music anime movies shows other software games isos books" -## FUNCTIONS -help () -{ - >&2 cat <<-EOF - Usage: $PROG [options] query - Options: - -h Show this help message and exit - -r Skip getting pages and use last results - -s OPTION Sort results based on the specified OPTION - Available options: seeds, size, name - -m MODULE Select a module, if MODULE is 'list', - lists out available modules - -c CATEGORY Select category - -f Do not list files - -d Download without confirming - EOF +logn() { >&2 printf '%s\n' "$*"; } +die() { + logn "$@" + exit 1 } - -log () { >&2 printf '%s' "$*"; } -logn () { >&2 printf '%s\n' "$*"; } -die () { logn "$@"; exit 1; } - -confirm() -{ - log "$1" +confirm() { + >&2 printf '%s' "$1" head -n 1 | grep -q "[yY]" } -dependencies () -{ - for p in $deps - do - if ! command -v "$p" > /dev/null - then - logn "E: Program '$p' not found." - error=1 - fi - done - [ "${error:-0}" -eq 1 ] && exit 1 -} - # Remove temp files and quit -cleanup () -{ - for file in $files - do eval "rm -f \$$file" +cleanup() { + for file in $files; do + eval "rm -f \$$file" done } -list_modules () { find -L "$MODULES_PATH" -type f -printf "%f\n"; } - -# get a query from user based on MENUCMD -get_query () -{ - isOnline || exit 1 - if [ "${query:="$*"}" ] - then - printf "%s" "$query" - else - log ' > ' - head -n 1 - fi | tr ' ' '+' -} - -# Select a result from the result file sorterd with sort_results -# and select with fzf -select_result () -{ - command -v sort_results > /dev/null || sort_results() { sort -k3 -n -r; } - awk '{print NR, $0}' "$results" | - sort_results | - column -t -l 3 | - fzf -m --with-nth 2.. | - awk '{print $1}' -} - -show_files() -{ - hash="${1##*btih:}" - hash="${hash%%&*}" - - # Download the torrent file from a torrent website - curl -s "https://itorrents.org/torrent/${hash}.torrent" > "$tmp"/.torrent - transmission-show "$tmp"/.torrent | sed -n '/^FILES/,$p' | head -n -1 | tail -n +3 >&2 - rm -f "$tmp"/.torrent -} +list_modules() { find -L "$MODULES_PATH" -type f -printf "%f\n"; } trap "exit 1" INT trap "cleanup" EXIT ## OPTIONS skip=0 -while getopts ":hm:rs:c:fd" opt -do +while getopts ":hm:rs:c:fd" opt; do case $opt in - h) help && exit ;; - c) - [ "$OPTARG" = "list" ] && >&2 printf '%s\n' "$categories" && exit - category="$(printf '%s\n' "$categories" | tr ' ' '\n' | grep -m 1 "^$OPTARG")" - [ -z "$category" ] && die "No valid category for '$OPTARG'" - logn "category: $category" ;; - f) noaskfiles="1" ;; - d) noaskdownload="1" ;; - m) - [ "$OPTARG" = "list" ] && list_modules && exit - module="$(list_modules | grep -m 1 "^$OPTARG")" - [ -z "$module" ] && die "No valid module for '$OPTARG'" - logn "module: $module" ;; - r) - [ ! -r "$results" ] && die "No previous results found." - skip=1 ;; - s) - case $OPTARG in - "seeds") sort_results() { sort -k3 -n -r; } ;; - "size") sort_results() { sort -k2 -h -r; } ;; - "name") sort_results() { sort -k4; } ;; - *) die "argument '$OPTARG' not seeds,size,name" ;; - esac ;; - :) die "Option -$OPTARG requires an argument" ;; - ?) die "Invalid option: -$OPTARG" ;; + h) + >&2 cat <<-EOF + Usage: $PROG [options] query + Options: + -h Show this help message and exit + -r Skip getting pages and use last results + -s OPTION Sort results based on the specified OPTION + Available options: seeds, size, name + -m MODULE Select a module, if MODULE is 'list', + lists out available modules + -c CATEGORY Select category + -f Do not list files + -d Download without confirming + EOF + + exit + ;; + c) + [ "$OPTARG" = "list" ] && >&2 printf '%s\n' "$categories" && exit + category="$(printf '%s\n' "$categories" | tr ' ' '\n' | grep -m 1 "^$OPTARG")" + [ -z "$category" ] && die "No valid category for '$OPTARG'" + logn "category: $category" + ;; + f) noaskfiles="1" ;; + d) noaskdownload="1" ;; + m) + [ "$OPTARG" = "list" ] && list_modules && exit + module="$(list_modules | grep -m 1 "^$OPTARG")" + [ -z "$module" ] && die "No valid module for '$OPTARG'" + logn "module: $module" + ;; + r) + [ ! -r "$results" ] && die "No previous results found." + skip=1 + ;; + s) + case $OPTARG in + "seeds") sort_results() { sort -k3 -n -r; } ;; + "size") sort_results() { sort -k2 -h -r; } ;; + "name") sort_results() { sort -k4; } ;; + *) die "argument '$OPTARG' not seeds,size,name" ;; + esac + ;; + :) die "Option -$OPTARG requires an argument" ;; + ?) die "Invalid option: -$OPTARG" ;; esac done shift $((OPTIND - 1)) -dependencies +for p in $deps; do + if ! command -v "$p" >/dev/null; then + logn "E: Program '$p' not found." + error=1 + fi +done +[ "${error:-0}" -eq 1 ] && exit 1 # Get the torrents with module -if [ $skip -ne 1 ] -then +if [ $skip -eq 1 ]; then + module="$(tail -n 1 "$links")" +else mkdir -p "$tmp" - query="$(get_query "$*")" + query="$( + if [ "${query:="$*"}" ]; then + printf "%s" "$query" + else + >&2 printf ' > ' + head -n 1 + fi | tr ' ' '+' + )" [ "$query" ] || exit 1 - # Get results - rm -f "$results" "$links" - # shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 . "$MODULES_PATH/$module" + rm -f "$results" "$links" get_torrents [ -f "$results" ] || die "No results." - # Save which module was used - printf "%s\n" "$module" >> "$links" -else - module="$(tail -n 1 "$links")" + # Save which module was used (hack) + printf "%s\n" "$module" >>"$links" fi +command -v sort_results >/dev/null || sort_results() { sort -k3 -n -r; } # select result from "$results" -for choice in $(select_result | xargs) -do - printf 'choice: %s\n' "$(sed -n "${choice}p" "$results" | cut -f 3-)" - magnet="$(get_magnet "$choice")" - [ "$magnet" ] || exit 1 - - if [ -z "$noaskfiles" ] && confirm 'files?'; then - show_files "$magnet" - fi - - if [ "$noaskdownload" ] || confirm 'download?' - then - [ "$category" ] || category="$(printf '%s' "$categories" | tr ' ' '\n' | fzf)" - [ "$category" ] || exit 2 - transmission-remote debuc.com -a "$magnet" -w "/downloads/$category" - elif confirm "copy?" - then - echo "$magnet" | clipp - fi +for choice in $( + # Select result(s) from the result file sorted with sort_results + # with fzf + awk '{print NR, $0}' "$results" | + sort_results | + column -t -l 3 | + fzf -m --with-nth 2.. | + awk 'BEGIN{OFS=" "} {print $1}' +); do + + printf 'choice: %s\n' "$(sed -n "${choice}p" "$results" | cut -f 3-)" + magnet="$(get_magnet "$choice")" + [ "$magnet" ] || exit 1 + + if [ -z "$noaskfiles" ] && confirm 'files?'; then + hash="${1##*btih:}" + hash="${hash%%&*}" + + # Download the torrent file from a torrent website + curl -s "https://itorrents.org/torrent/${hash}.torrent" >"$tmp"/.torrent + transmission-show "$tmp"/.torrent | sed -n '/^FILES/,$p' | head -n -1 | tail -n +3 >&2 + rm -f "$tmp"/.torrent + fi + + if [ "$noaskdownload" ] || confirm 'download?'; then + [ "$category" ] || category="$(printf '%s' "$categories" | tr ' ' '\n' | fzf)" + [ "$category" ] || exit 2 + transmission-remote debuc.com -a "$magnet" -w "/downloads/$category" + elif confirm "copy?"; then + echo "$magnet" | clipp + fi done -- cgit v1.2.3 From 24f0ae1ca95a64ae065b2c7fcc129709b3b61091 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 21:02:26 +0200 Subject: checkpoint --- bin/menuscripts/tsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index 0e2b64d..d07d0d5 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -46,7 +46,6 @@ trap "exit 1" INT trap "cleanup" EXIT ## OPTIONS -skip=0 while getopts ":hm:rs:c:fd" opt; do case $opt in h) @@ -107,7 +106,7 @@ done [ "${error:-0}" -eq 1 ] && exit 1 # Get the torrents with module -if [ $skip -eq 1 ]; then +if [ "${skip:-0}" -eq 1 ]; then module="$(tail -n 1 "$links")" else mkdir -p "$tmp" -- cgit v1.2.3 From 74deca210112c697225d4868fec1edf837c5a457 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 21:04:36 +0200 Subject: checkpoint --- bin/menuscripts/tsh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index d07d0d5..ea582d8 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -42,7 +42,7 @@ cleanup() { list_modules() { find -L "$MODULES_PATH" -type f -printf "%f\n"; } -trap "exit 1" INT +trap "exit 2" INT trap "cleanup" EXIT ## OPTIONS @@ -103,7 +103,7 @@ for p in $deps; do error=1 fi done -[ "${error:-0}" -eq 1 ] && exit 1 +[ "${error:-0}" -eq 1 ] && exit 3 # Get the torrents with module if [ "${skip:-0}" -eq 1 ]; then @@ -119,7 +119,7 @@ else head -n 1 fi | tr ' ' '+' )" - [ "$query" ] || exit 1 + [ "$query" ] || exit 4 # shellcheck source=/usr/local/lib/$PROG/nyaa.sh disable=SC1091 . "$MODULES_PATH/$module" @@ -132,6 +132,7 @@ else printf "%s\n" "$module" >>"$links" fi +# Default sorting if unset command -v sort_results >/dev/null || sort_results() { sort -k3 -n -r; } # select result from "$results" @@ -147,7 +148,7 @@ for choice in $( printf 'choice: %s\n' "$(sed -n "${choice}p" "$results" | cut -f 3-)" magnet="$(get_magnet "$choice")" - [ "$magnet" ] || exit 1 + [ "$magnet" ] || exit 5 if [ -z "$noaskfiles" ] && confirm 'files?'; then hash="${1##*btih:}" @@ -159,9 +160,9 @@ for choice in $( rm -f "$tmp"/.torrent fi - if [ "$noaskdownload" ] || confirm 'download?'; then + if [ -z "$noaskdownload" ] && confirm 'download?'; then [ "$category" ] || category="$(printf '%s' "$categories" | tr ' ' '\n' | fzf)" - [ "$category" ] || exit 2 + [ "$category" ] || exit 6 transmission-remote debuc.com -a "$magnet" -w "/downloads/$category" elif confirm "copy?"; then echo "$magnet" | clipp -- cgit v1.2.3 From 6251d6ba1054cd79387f0f88ce25d2f4bc8b78c4 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 21:42:14 +0200 Subject: checkpoint --- bin/common/gt | 24 ++++++++++-------------- bin/common/gt-st | 8 ++++++-- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'bin') diff --git a/bin/common/gt b/bin/common/gt index 48321af..477adfc 100755 --- a/bin/common/gt +++ b/bin/common/gt @@ -6,6 +6,7 @@ # - git # - $EDITOR: -e # - parallel: optional, if installed will run the commands on all repos with parallel +# - gt-[cmd,st,sync] repos=$HOME/sync/share/git-track.txt # prevent file not found errors @@ -36,17 +37,6 @@ fetch() { done } -sync_status() { - if [ "$parallel" ]; then - parallel --colsep ' ' gt-sync {1} {2} <"$repos" - else - IFS=' ' - while read -r repo remote_url; do - gt-sync "$repo" "$remote_url" - done <"$repos" - fi -} - # no options if [ -z "$1" ]; then help @@ -55,7 +45,7 @@ fi [ "$(wc -l <"$repos")" -gt 0 ] || exit 0 -while getopts ":a:c:f:lsheuy" opt; do +while getopts ":a:c:f:lsheu" opt; do case "$opt" in a) if ! cd "$OPTARG" 2>/dev/null; then @@ -84,12 +74,18 @@ while getopts ":a:c:f:lsheuy" opt; do fi ;; s) cut -f 1 -d ' ' "$repos" | xargs -I{} gt-st {} ;; - y) sync_status ;; l) cut -f 1 -d ' ' "$repos" ;; e) $EDITOR "$repos" ;; f) repos="$OPTARG" ;; u) - sync_status | awk -F ':' '/x$/ {print $1}' | + if [ "$parallel" ]; then + parallel --colsep ' ' gt-sync {1} {2} <"$repos" + else + IFS=' ' + while read -r repo remote_url; do + gt-sync "$repo" "$remote_url" + done <"$repos" + fi | awk -F ':' '/x$/ {print $1}' | if [ "$parallel" ]; then parallel gt-cmd {} pull else diff --git a/bin/common/gt-st b/bin/common/gt-st index 98184b9..43443cd 100755 --- a/bin/common/gt-st +++ b/bin/common/gt-st @@ -14,11 +14,15 @@ if [ ! -d "$repo" ]; then fi # replace line with status -status="$(git -C "$repo" status --porcelain 2>/dev/null | +status="$(git -C "$repo" status --porcelain 2>/dev/null | awk '{print $1}' | sort | uniq | tr -s '?' | tr -d '\n')" remote="$(git -C "$repo" branch -v 2>/dev/null | sed '/^*/!d;s/ahead/↑/;s/behind/↓/;s/[^↓↑]*//g')" -printf '%s %s %s\n' "$repo_pretty" "$status" "$remote" +if [ "$status" ] || [ "$remote" ]; then + printf '%s: \033[0;31m%s %s\033[0m\n' "$repo_pretty" "$status" "$remote" +else + printf '%s\n' "$repo_pretty" +fi -- cgit v1.2.3