diff options
Diffstat (limited to 'urititle')
-rwxr-xr-x | urititle | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash scheme=$(printf "%s\n" "$1" | uricut -s) path=$(printf "%s\n" "$1" | uricut -p) qs=$(printf "%s\n" "$1" | uricut -q) @@ -37,7 +37,17 @@ if [ "$port" ];then fi ;; gemini) - printf "title: %s\n" "$(gemini-get "$1" | grep '^#' | head -n1 | sed 's/^#* *//g')" + first=1 + gemini-get "$1" | while read -r line;do + if [ "$first" ];then + unset first + if ! printf "%s\n" "$line" | grep '^[^ ]* text/gemini' 2>&1 >/dev/null;then + printf "title: %s\n" "$(printf "%s\n" "$line" | tr '\t' ' ' | tr -s ' ' | cut '-d ' -f2-)" + fi + else + printf "title: %s\n" "$(printf "%s\n" "$line" | grep '^#' | sed 's/^#* *//g')" + fi + done | head -n1 ;; magnet) printf "title: %s\n" "$(printf "%s\n" "$1" | tr '&' '\n' | grep ^dn= | cut -d= -f2- | uriunescape)" |