From 1e7ff368f1120182c04f9a284263b973bed689d0 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Mon, 19 Sep 2022 19:48:41 -0400 Subject: [PATCH] Updated lhpaste to use pbcli (linux) --- .local/dotfiles/functions/lhpaste.zsh | 139 +------------------ .local/dotfiles/functions/update-solrepo.zsh | 9 -- 2 files changed, 4 insertions(+), 144 deletions(-) delete mode 100644 .local/dotfiles/functions/update-solrepo.zsh diff --git a/.local/dotfiles/functions/lhpaste.zsh b/.local/dotfiles/functions/lhpaste.zsh index f3f2efd..41fddc9 100644 --- a/.local/dotfiles/functions/lhpaste.zsh +++ b/.local/dotfiles/functions/lhpaste.zsh @@ -1,139 +1,8 @@ function lhpaste() { - local server_url="https://paste.linux-help.org" + local server_url="https://paste.linux-help.org/" + local expire="1day" - local o_apikey - local o_expire=(--expire 60) - local o_help - local o_lang - local o_name - local o_private - local o_reply - local o_title - local o_url=(--url https://paste.linux-help.org) - local args + #zparseopts -D -E -F - - if [[ -n "$LHPASTE_API_KEY" ]]; then - o_apikey=(--apikey "$LHPASTE_API_KEY") - fi - - if [[ -n "$LHPASTE_NAME" ]]; then - o_name=(--name "$LHPASTE_NAME") - else - o_name=(--name "$USER") - fi - - if [[ -n "$LHPASTE_SERVER_URL" ]]; then - o_url=(--url "$LHPASTE_SERVER_URL") - fi - - zparseopts -D -K -M -- \ - h=o_help -help=h \ - e:=o_expire -expire:=e \ - l:=o_lang -lang:=l \ - n:=o_name -name:=n \ - p=o_private -private=p \ - r:=o_reply -reply:=r \ - t:=o_title -title:=t \ - u:=o_url -url:=u \ - a:=o_apikey -apikey:=a - - if [[ -n "$o_help" ]]; then - cat <<-EOF -USAGE: $funcstack[1] [OPTIONS] [FILE] - -OPTIONS: - - --expire MIN, -e MIN Set paste expire time in minutes (Default: $o_expire[2]) - --lang LANG, -l LANG Set paste language - --name TEXT, -n TEXT Set paste author name (Default: $o_name[2]) - --private, -p Set paste private - --reply ID, -r ID Set paste in reply to ID - --title TEXT, -t TEXT Set paste title text - --url URL, -u URL Set paste server URL (Default: $o_url[2]) - --apikey TEXT, -a TEXT Set API-KEY for Stikked Paste access - -ENVIRONMENT: - - LHPASTE_NAME Set the name to use instead of the default value of \$USER - LHPASTE_SERVER_URL Set the server base url to the stikked server - LHPASTE_API_KEY Set the apikey to use the stikked server API -EOF - return 0 - fi - - #echo "DEBUG:" - #echo "expire = $o_expire[2]" - #echo "lang = $o_lang[2]" - #echo "name = $o_name[2]" - #echo "help = $o_help" - #echo "private = $o_private" - #echo "reply = $o_reply[2]" - #echo "title = $o_title[2]" - #echo "url = $o_url[2]" - #echo "apikey = $o_apikey[2]" - - if [[ -n "$o_expire" ]]; then - args+=(-d "expire=$o_expire[2]") - fi - - if [[ -n "$o_lang" ]]; then - args+=(-d "lang=$o_lang[2]") - fi - - if [[ -n "$o_name" ]]; then - args+=(-d "name=$o_name[2]") - fi - - if [[ -n "$o_private" ]]; then - if [[ "$o_private" == "-p" || "$o_private" == "--private" || "$o_private" == "-p1" ]]; then - args+=(-d "private=1") - elif [[ "$o_private" == "-p0" ]]; then - args+=(-d "private=0") - fi - fi - - if [[ -n "$o_reply" ]]; then - args+=(-d "name=$o_reply[2]") - fi - - if [[ -n "$o_title" ]]; then - args+=(-d "name=$o_title[2]") - fi - - #if [[ -n "$o_apikey" ]]; then - # apikey="$o_apikey[2]" - #fi - - if [[ -n "$o_url" ]]; then - server_url="$o_url[2]/api/create" - if [[ -n "$o_apikey" ]]; then - server_url="$server_url?apikey=$o_apikey[2]" - fi - fi - - #echo "args = $args" - #echo "opts = $*" - #return 0 - - if [[ -t 1 ]]; then - if test $# = 0; then - if test -t 0; then - echo "Missing filename" 1>&2 - return - fi - curl $args --data-urlencode text@- "$server_url" - else - curl $args --data-urlencode text@"$1" "$server_url" - fi - else - if test $# = 0; then - if test -t 0; then - echo "Missing filename" 1>&2 - return - fi - curl $args --data-urlencode text@- "$server_url" - else - curl $args --data-urlencode text@"$1" "$server_url" - fi - fi + pbcli --host="$server_url" --expire="$expire" } diff --git a/.local/dotfiles/functions/update-solrepo.zsh b/.local/dotfiles/functions/update-solrepo.zsh deleted file mode 100644 index 58fc147..0000000 --- a/.local/dotfiles/functions/update-solrepo.zsh +++ /dev/null @@ -1,9 +0,0 @@ -function update-solrepo() { - REPO_DIR=${REPO_DIR-/mnt/storage/repo/solus} - - pushd "$REPO_DIR" 2>&1 >/dev/null - eopkg index - rsync -avhHi --delete-after "${REPO_DIR}/" root@bastion:/srv/repo/solus/ - popd 2>&1 >/dev/null -} -