From 0f99bf0d21bc2b198ab91e393b1f31cee0d8f295 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 9 Aug 2022 23:15:02 +0300 Subject: [PATCH] ref: rayso func --- sub/bash/functions | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sub/bash/functions b/sub/bash/functions index 13fd0cd..e7c4a16 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -219,12 +219,16 @@ split-file() { # returns url to code previewer rayso() { - test -z "$1" && return 1 - local CODE FILENAME + local CODE TITLE - CODE="$(cat "$1" | base64)" - FILENAME="$(basename "$1")" + if [[ -n "$1" ]]; then + CODE="$(cat "$1" | base64)" + TITLE="$(basename "$1")" + else + CODE="$(cat | base64)" + TITLE="Code" + fi - echo "https://ray.so/?colors=candy&background=true&darkMode=true&padding=64&title=${FILENAME}&code=${CODE}&language=auto" + echo "https://ray.so/?colors=candy&background=true&darkMode=true&padding=64&title=${TITLE}&code=${CODE}&language=auto" }