diff options
author | xengineering <me@xengineering.eu> | 2022-08-04 19:10:12 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2022-08-04 19:10:12 +0200 |
commit | a7ed17f7de8c37fed9b2d5ee80d5483194a79cd4 (patch) | |
tree | 069d87602769d7cb0743120e119d0d06ac84df1b | |
parent | a4e85dc07d8f5f45e1571fab459d46dff77b2ef8 (diff) | |
download | scripts-a7ed17f7de8c37fed9b2d5ee80d5483194a79cd4.tar scripts-a7ed17f7de8c37fed9b2d5ee80d5483194a79cd4.tar.zst scripts-a7ed17f7de8c37fed9b2d5ee80d5483194a79cd4.zip |
Only display URL aliases instead of full URL
-rwxr-xr-x | url.sh | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -36,21 +36,32 @@ then fi # let user select the URL -closer="close menu" -line="$(sed "$ a ${closer}" < "${data_abs}" | ${menu} -i -l 10)" -selection="$(echo "${line}" | awk -F '\t' '{print $1}')" +closer="[close menu]" +options="$(awk -F '\t' '{print $2}' < "${data_abs}" | sed "$ a ${closer}")" +key="$(echo "${options}" | ${menu} -i -l 10)" -# exit or open URL in browser -if [ "${selection}" = "${closer}" ] +# close if user selected the close entry or stopped menu with ESC +if [ "${key}" = "${closer}" ] || [ "${key}" = "" ] then exit 0 +fi -# exit if nothing is selected -elif [ "${selection}" = "" ] -then - exit 0 +# search for the selected key in data file +url="" +while read -r line +do + if [ "$(echo "${line}" | awk -F '\t' '{print $2}')" = "${key}" ] + then + if [ "${url}" = "" ] + then + url="$(echo "${line}" | awk -F '\t' '{print $1}')" + else + # warn if multiple URLs have this key + echo "More than one URL in data file matching selected key!" 1>&2 + break + fi + fi +done < "${data_abs}" # open selected URL in browser -else - firefox "${selection}" -fi +firefox "${url}" |