From: Siraaj Khandkar Date: Thu, 20 Apr 2023 19:47:17 +0000 (-0400) Subject: Format p X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=980f3633552f4b4f48b8e49a5e70fd495102c25c;p=khome.git Format p --- diff --git a/home/bin/p b/home/bin/p index b4a9cab..507d578 100755 --- a/home/bin/p +++ b/home/bin/p @@ -47,18 +47,22 @@ main() { local name file records i meta data datum case "$#" in - 0) - echo "$usage" >&2 - return 1;; - 1) - file="$default_file" - name="$1";; - 2) - file="$1" - name="$2";; - *) - echo "$usage" >&2 - return 1;; + 0) + echo "$usage" >&2 + return 1 + ;; + 1) + file="$default_file" + name="$1" + ;; + 2) + file="$1" + name="$2" + ;; + *) + echo "$usage" >&2 + return 1 + ;; esac records=$(find "$name" "$file") @@ -67,14 +71,17 @@ main() { # XXX Even an empty result will count as one line after echo, so need to filter: case "$(echo "$records" | grep -vc '^$')" in - 0) - echo '[ERROR] Found nothing.' >&2 - exit 1;; - 1) - datum="$data";; - *) - i=$(echo "$meta" | column -t | fzf | awk '{print $1}') - datum=$(echo "$data" | awk -v i="$i" 'NR == i');; + 0) + echo '[ERROR] Found nothing.' >&2 + exit 1 + ;; + 1) + datum="$data" + ;; + *) + i=$(echo "$meta" | column -t | fzf | awk '{print $1}') + datum=$(echo "$data" | awk -v i="$i" 'NR == i') + ;; esac # XXX Intentionally avoiding newline: