bash: fix shellcheck errors in .bash_functions
All checks were successful
ci/woodpecker/push/lint Pipeline was successful

Signed-off-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2024-06-05 20:04:49 +02:00
parent 5e88bf3f74
commit ef9e2a036f
2 changed files with 16 additions and 12 deletions

View file

@ -1,6 +1,7 @@
### Funktionen
#!/bin/bash
function rgf {
if [[ "$1" == "--help" ]]; then
# shellcheck disable=SC2140
echo "Finde alle Dateien die "\$1" im Namen haben."
echo ""
echo " Usage: rgf <string>"
@ -11,14 +12,15 @@ function rgf {
return 1
fi
if command -v rg >/dev/null ; then
rg --ignore-case --files --hidden --glob=!.git/ *"$1"*
rg --ignore-case --files --hidden --glob=!.git/ --*"$1"*
else
echo "[INFO] ripgrep ist nicht installiert... suche mit 'find'"
find . -type f -not -path '*/\.git/*' -name *"$1"*
find . -type f -not -path '*/\.git/*' -name -- *"$1"*
fi
}
function rgi {
if [[ "$1" == "--help" ]]; then
# shellcheck disable=SC2140
echo "Finde alle Dateien die "\$1" im Inhalt haben."
echo ""
echo " Usage: rgi <string>"
@ -78,7 +80,7 @@ EOF
(git checkout --quiet -b "$2" && git push --set-upstream "$(git remote | head -n 1)" "$2" && echo '>>> Create new branch "'"$2"'"') || (git checkout --quiet "$2" > /dev/null 2>&1 && echo '>>> Branch already exists, checking out... ')
;;
*)
if [ ! -z $1 ] ; then
if [ -n "$1" ] ; then
(echo ">>> Try local checkout" && git checkout --quiet "$1" > /dev/null 2>&1) || (echo ">>> Try remote checkout" && git checkout --quiet -b "$1" origin/"$1" > /dev/null 2>&1 || echo ">>> Unkown branch!")
else
(git checkout --quiet master > /dev/null 2>&1 && echo '>>> Try checking out master') || (git checkout --quiet main > /dev/null 2>&1 && echo '>>> Try checking out main') || (git checkout --quiet release > /dev/null 2>&1 && echo '>>> Try checking out release')
@ -94,7 +96,7 @@ function glogs {
else
ncommits="$1";
fi;
git log --pretty=format:'%C(auto) %<|(16,trunc)%h %Cred %G?%Creset %<|(60,trunc)%s %<(20,trunc)%Cgreen%cr%Creset %<(15,trunc)%Cblue%an%Creset %Cred%D' --graph --all -$ncommits
git log --pretty=format:'%C(auto) %<|(16,trunc)%h %Cred %G?%Creset %<|(60,trunc)%s %<(20,trunc)%Cgreen%cr%Creset %<(15,trunc)%Cblue%an%Creset %Cred%D' --graph --all -"$ncommits"
}
function gp {
git pull "$@"
@ -104,13 +106,15 @@ function mdtoc {
}
# "scrolle" durch die commit-history
ghist() {
# shellcheck disable=2155
local total_commits=$(git rev-list HEAD --count)
local current_commit=$total_commits
show_commit_diff() {
if [ $current_commit -le $total_commits ] && [ $current_commit -ge 1 ]; then
if [ "$current_commit" -le "$total_commits" ] && [ "$current_commit" -ge 1 ]; then
# shellcheck disable=2155
local commit_hash=$(git rev-list --reverse HEAD | sed -n "${current_commit}p")
git --no-pager show $commit_hash
git --no-pager show "$commit_hash"
fi
}
@ -122,15 +126,17 @@ ghist() {
echo "-----------------------------------------------------------"
echo "Navigation: N - Next Commit, P - Previous Commit, Q - Quit"
echo "-----------------------------------------------------------"
read -n1 -s option
read -r -n1 -s option
case $option in
p|P)
# shellcheck disable=2086
if [ $current_commit -gt 1 ]; then
((current_commit--))
fi
;;
n|N)
# shellcheck disable=2086
if [ $current_commit -lt $total_commits ]; then
((current_commit++))
fi

View file

@ -20,8 +20,7 @@ function update {
git stash
git pull
else
# shellcheck disable=SC2035
scan *
scan -- *
fi
cd .. > /dev/null
fi
@ -39,5 +38,4 @@ function scan {
if [ "$1" != "" ]; then cd "$1" || exit > /dev/null; fi
echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}"
# shellcheck disable=SC2035
scan *
scan -- *