From f8d4fc9b4c51d6cde723127ee238bfa1f6d9992b Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 20 Sep 2021 08:57:20 +0200 Subject: [PATCH] bin: little corrections --- .local/bin/scripts/ex | 4 +--- .local/bin/scripts/git-origin | 4 ++-- .local/bin/scripts/grpf | 3 +++ .local/bin/scripts/help | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100755 .local/bin/scripts/grpf diff --git a/.local/bin/scripts/ex b/.local/bin/scripts/ex index ec68787..804e153 100755 --- a/.local/bin/scripts/ex +++ b/.local/bin/scripts/ex @@ -5,18 +5,16 @@ for arg do if test -r "$arg"; then case "$arg" in *.tar.bz2) tar xjf "$arg" ;; - *.tar.gz) tar xzf "$arg" ;; + *.tar.*|*.tar) tar --extract --file "$arg";; *.bz2) bunzip2 "$arg" ;; *.rar) unrar x "$arg" ;; *.gz) gunzip "$arg" ;; - *.tar) tar xf "$arg" ;; *.tbz2) tar xjf "$arg" ;; *.tgz) tar xzf "$arg" ;; *.zip|*.jar) unzip "$arg" ;; *.Z) uncompress "$arg";; *.7z) 7z x "$arg" ;; *.deb) ar x "$arg" ;; - *.tar.xz) tar xf "$arg" ;; *.zst) unzstd "$arg" ;; *) echo "'$arg' cannot be extracted by ex" ;; esac diff --git a/.local/bin/scripts/git-origin b/.local/bin/scripts/git-origin index 3692bec..2730d45 100755 --- a/.local/bin/scripts/git-origin +++ b/.local/bin/scripts/git-origin @@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/sh -e # set repo as origin and set all branches upstream to a corresponding remote branch, if available git remote remove origin 2>/dev/null git remote add origin $(git-repo "$@") -git remote -v && git fetch || ( last=$? && echo "git fetch failed, aborting\!" && return $last ) +git remote -v && git fetch git branch | sed 's/ //g' | sed 's/*//' | while read branch do test $(git branch -a | grep origin/$branch | wc -l) -gt 0 && git branch -u origin/$branch $branch diff --git a/.local/bin/scripts/grpf b/.local/bin/scripts/grpf new file mode 100755 index 0000000..9e73ae7 --- /dev/null +++ b/.local/bin/scripts/grpf @@ -0,0 +1,3 @@ +#!/bin/sh +# Grep in files matching the name pattern given as first argument +find -name "$1" | while read f; do grep --color=always --line-number --ignore-case -H "${@:2}" "$f"; done | less -F diff --git a/.local/bin/scripts/help b/.local/bin/scripts/help index 44d4ef8..1cb8edf 100755 --- a/.local/bin/scripts/help +++ b/.local/bin/scripts/help @@ -9,5 +9,6 @@ case $1 in info --vi-keys $(test $search != zsh && echo --index-search=$search) zsh || LESS="$LESS +/^ *${@:$#} *\\[" man zshall;; (vlc) unbuffer vlc --full-help "${@:2}" | $paginate;; (gh|chordpro) $@ --help | $paginate;; + (caddy) $1 help ${@:2} | $paginate;; (*) info "$1" -w | grep -v "manpages" && pinfo "$@" || man "$@" || ( "$@" --help || "$@" -help ) 2>&1 | $paginate;; esac