1
0
포크 0
소스 검색

Add imgur upload/delete scripts. Fix new bin locations.

master
SolitudeSF 3 년 전
부모
커밋
8e6db548ed
No known key found for this signature in database
GPG 키 ID: 789B06817C385387
  1. 2
      bin/edit-script
  2. 21
      bin/imgur
  3. 15
      bin/imgur-delete
  4. 2
      elvish/lib/completers.elv

2
bin/edit-script

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
[ -z "$1" ] && return 1 || f=$(command -v "$1")
if [ -z "$f" ]; then
f="$HOME/bin/$1"
f="$HOME/.local/bin/$1"
$EDITOR "$f"
[ -f "$f" ] && chmod +x "$f"
else

21
bin/imgur

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
#!/usr/bin/env elvish
resp = [&]
id = (from-json <~/sns/imgur.json)[SolitudeAnon][id]
command = [-sLX POST 'https://api.imgur.com/3/image' --data-binary '@-' -H "Authorization: Client-ID "$id ]
if (not-eq ?(tty -s) $ok) {
resp = (all | base64 | curl $@command | from-json)
} elif (> (count $args) 0) {
resp = (base64 $args[0] | curl $@command | from-json)
} else {
exit 1
}
if (and (has-key $resp success) (eq $resp[success] $true)) {
echo Uploaded to $resp[data][link]
echo Delete hash: $resp[data][deletehash]
} else {
echo Upload failed
exit 1
}

15
bin/imgur-delete

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
#!/usr/bin/env elvish
if (== (count $args) 0) {
echo Provide deletion hash
exit 1
}
id = (from-json <~/sns/imgur.json)[SolitudeAnon][id]
resp = (curl -sLX DELETE 'https://api.imgur.com/3/image/'$args[0] -H 'Authorization: Client-ID '$id | from-json)
if (and (has-key $resp success) (eq $resp[success] $true)) {
echo Image deleted
} else {
echo Failed to delete image
exit 1
}

2
elvish/lib/completers.elv

@ -228,7 +228,7 @@ edit:completion:arg-completer[brl] = [@cmd]{ @@ -228,7 +228,7 @@ edit:completion:arg-completer[brl] = [@cmd]{
}
edit:completion:arg-completer[promotescript] = [@cmd]{
pwd=~/bin put *
pwd=~/.local/bin fd -t f
}
edit:completion:arg-completer[edit-script] = $edit:complete-sudo~

불러오는 중...
취소
저장