19-08-2024
-ajout des mots-clés dans le presse-papier -update possible à partir un repo Github privé
This commit is contained in:
55
bashbirds.sh
55
bashbirds.sh
@@ -1,20 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VERSION="v0.6b"
|
||||
### ChangeNotes: Notification template changes for: gotify(new), DSM(improved), SMTP(deprecation alternative).
|
||||
|
||||
dotenv () {
|
||||
set -a
|
||||
# shellcheck disable=SC1091
|
||||
[ -f ".env" ] && . ".env" || echo -e "${red}\nNo .env file found ! No token for gotify.${reset}"
|
||||
set +a
|
||||
}
|
||||
|
||||
dotenv
|
||||
|
||||
### ChangeNotes: .
|
||||
Github="https://github.com/bruno21/bashbirds"
|
||||
RawUrl="https://raw.githubusercontent.com/bruno21/bashbirds/main/bashbirds.sh"
|
||||
# Repo normal:
|
||||
#RawUrl="https://raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
|
||||
# Repo privé:
|
||||
RawUrl="https://x-access-token:$GITHUB_TOKEN@raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
|
||||
|
||||
### Variables for self updating
|
||||
ScriptArgs=( "$@" )
|
||||
ScriptPath="$(readlink -f "$0")"
|
||||
ScriptWorkDir="$(dirname "$ScriptPath")"
|
||||
|
||||
echo ScriptWorkDir
|
||||
ScriptPath="$(readlink -f "$0")" # /Users/bruno/Documents/Scripts/bashbirds/bashbirds.sh
|
||||
ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbirds
|
||||
|
||||
### Check if there's a new release of the script:
|
||||
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
|
||||
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")"
|
||||
echo $LatestRelease
|
||||
echo $VERSION
|
||||
|
||||
red="\033[1;31m"
|
||||
greenbold="\033[1;32m"
|
||||
@@ -25,13 +38,6 @@ bold="\033[1m"
|
||||
underline="\033[4m"
|
||||
reset="\033[0m"
|
||||
|
||||
search="$1"
|
||||
#echo "$search"
|
||||
|
||||
dir=$(dirname "$0")
|
||||
#echo $dir
|
||||
#file="liste_oiseaux.txt"
|
||||
#echo $file
|
||||
|
||||
req2() {
|
||||
f_md="liste_oiseaux.md"
|
||||
@@ -76,6 +82,7 @@ req1() {
|
||||
#echo "$result1"
|
||||
|
||||
array2=()
|
||||
keywords=()
|
||||
cmpt=1
|
||||
while IFS='|' read -ra array2;
|
||||
do
|
||||
@@ -97,11 +104,24 @@ req1() {
|
||||
#echo "${#fr2} ; ${#aut2} ; ${#lat2} ; ${#en2} ; ${#or2} ; ${#fa2} ; ${#lnk2}"
|
||||
|
||||
echo
|
||||
printf "| %-3s | %-25s | %-25s | %-25s | %-20s | %-20s \n" "$cmpt" "$fr2" "$lat2" "$en2" "$or2" "$fa2"
|
||||
printf "\e[1m| %-3s | %-25s | %-25s | %-25s | %-20s | %-20s \e[0m\n" "$cmpt" "$fr2" "$lat2" "$en2" "$or2" "$fa2"
|
||||
printf "| %-3s | %-55s \n" "$cmpt" "$lnk2"
|
||||
printf "| %-3s | %-55s \n" "$cmpt" "$tag2"
|
||||
printf "\e[0;34m| %-3s | %-55s \e[0m\n" "$cmpt" "$tag2"
|
||||
keywords+=("$tag2")
|
||||
cmpt=$((cmpt+1))
|
||||
done <<< "$result1"
|
||||
|
||||
choose=$(echo -e "\nChoose a number to get keywords in your clipboard: ")
|
||||
read -e -p "$choose" choice
|
||||
|
||||
if [ "$choice" -ge "1" ] && [ "$choice" -le "$((cmpt-1))" ]; then
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v xsel)" ]; then
|
||||
xsel -b <<< "${keywords[$((choice-1))]}"
|
||||
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v pbcopy)" ]; then
|
||||
pbcopy <<< "${keywords[$((choice-1))]}"
|
||||
fi
|
||||
else echo "Wrong index !"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +197,8 @@ Help() {
|
||||
|
||||
while getopts "b:hm" options; do
|
||||
case "${options}" in
|
||||
b) Bird="${OPTARG}" ;;
|
||||
# b) Bird="${OPTARG}" ;;
|
||||
b) req1 "${OPTARG}" ;;
|
||||
m) req2 ;;
|
||||
v) printf "%s\n" "$VERSION" ; exit 0 ;;
|
||||
h|*) Help ; exit 2 ;;
|
||||
@@ -185,6 +206,7 @@ while getopts "b:hm" options; do
|
||||
done
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
: <<'END_COMMENT'
|
||||
echo "bird: $Bird"
|
||||
read -p "Pause: " choice
|
||||
|
||||
@@ -193,3 +215,4 @@ if [ $Bird == "all" ]; then
|
||||
elif [ -n $Bird ]; then
|
||||
req1 "$Bird"
|
||||
fi
|
||||
END_COMMENT
|
||||
Reference in New Issue
Block a user