Explorar el Código

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

master
SolitudeSF hace 2 años
padre
commit
8e6db548ed
No se encontró ninguna clave conocida en la base de datos para esta firma
Se han modificado 4 ficheros con 38 adiciones y 2 borrados
  1. 1
    1
      bin/edit-script
  2. 21
    0
      bin/imgur
  3. 15
    0
      bin/imgur-delete
  4. 1
    1
      elvish/lib/completers.elv

+ 1
- 1
bin/edit-script Ver fichero

@@ -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
- 0
bin/imgur Ver fichero

@@ -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
- 0
bin/imgur-delete Ver fichero

@@ -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
}

+ 1
- 1
elvish/lib/completers.elv Ver fichero

@@ -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~

Cargando…
Cancelar
Guardar