From 97ae8ca1d0c184e196d13f020a7a2d8811d1064c Mon Sep 17 00:00:00 2001 From: swytch Date: Mon, 25 May 2020 14:44:06 +0200 Subject: [PATCH] fix: general scripts improvements append `sed` commands instead of piping them (bibinput, bibshow) add dependencies (bibinput, bibshow) break forloop when bulding is done (compiler) --- .local/bin/bibinput | 11 ++++++----- .local/bin/bibshow | 3 ++- .local/bin/compiler | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.local/bin/bibinput b/.local/bin/bibinput index 8972393..841e5fe 100755 --- a/.local/bin/bibinput +++ b/.local/bin/bibinput @@ -7,16 +7,17 @@ # @created : Wednesday May 20, 2020 17:57:47 CEST # # @description : create a bibliography entry through dmenu +# @dependencies : dmenu ###################################################################### parse(){ if [ "$1" = "@" ]; then - grep "$1" "$file" | awk -F '{' '{print $2} ' | tr ',' '\n' | sort -r | sed '/^[[:space:]]*$/d' + grep "$1" "$file" | awk -F '{' '{print $2} ' | tr ',' '\n' | sed '/^[[:space:]]*$/d' | sort -r elif [ "$1" = "keywords" ]; then - grep "$1" "$file" | awk -F '"' '{print $2} ' | tr ' ' '\n' | sed 's/,//g' | sort -u | sed '/^[[:space:]]*$/d' + grep "$1" "$file" | awk -F '"' '{print $2} ' | tr ' ' '\n' | sed -e 's/,//g' -e '/^[[:space:]]*$/d' | sort -u else - grep "$1" "$file" | sed "s/,$//g" | awk -F '"' '{print $2} ' | sort | uniq + grep "$1" "$file" | sed "s/,$//g" | awk -F '"' '{print $2} ' | sort -u fi } @@ -88,7 +89,7 @@ if [ -z "$keyword" ]; then keyword_test="no" else keyword_test="$(printf "yes\nno" |dmenu -p "another keyword?")" - keyword_test=${keyword_test:-no} + keyword_test=${keyword_test:-"no"} fi while [ "$keyword_test" = "yes" ]; do keyword="$(input "keywords")" @@ -96,7 +97,7 @@ while [ "$keyword_test" = "yes" ]; do keyword_test="no" elif [ "${keywords#*"$keyword"}" != "$keywords" ]; then keyword_test="$(printf "yes\nno" |dmenu -p "keyword already given. another keyword?")" - keyword_test=${keyword_test:-no} + keyword_test=${keyword_test:-"no"} else keywords="$keywords, $keyword" keyword_test="$(printf "yes\nno" |dmenu -p "another keyword?")" diff --git a/.local/bin/bibshow b/.local/bin/bibshow index 27ab805..31ec1aa 100755 --- a/.local/bin/bibshow +++ b/.local/bin/bibshow @@ -7,12 +7,13 @@ # @created : Wednesday May 20, 2020 17:58:14 CEST # # @description : interactively display the infos in a .bib entry +# @dependencies : dmenu ###################################################################### file="$(find $HOME/documents/bibliographies/ -type f -not -path '*/\.*' | dmenu -l 20 -p "[bibshow] which bibliography?")" # the -not -path allows find to ignore hidden files -refs_list="$(sed 's/\t//g' "$file" | tr '\n' ' ' | sed 's/}\ /}\n/g')" +refs_list="$(sed -e 's/\t//g' "$file" | tr '\n' ' ' | sed -e 's/}\ /}\n/g')" [ -z $refs_list ] && exit 1; ref="$(echo "$refs_list" | dmenu -i -p 'infos?' -l 10)" diff --git a/.local/bin/compiler b/.local/bin/compiler index aaab5df..b65fed1 100755 --- a/.local/bin/compiler +++ b/.local/bin/compiler @@ -56,6 +56,7 @@ s_build(){ for tool in $sucklesstools; do if [ "$tool" = "$dirname" ]; then s_build + break 0 fi done