Commit 5fddc89a authored by nimrod's avatar nimrod
Browse files

Replace messy aliases of url encode/ decode with short scripts (which are...

Replace messy aliases of url encode/ decode with short scripts (which are checked by pre-commit), use fileinput for instead of messing with redirects.
parent 89c03b25
Loading
Loading
Loading
Loading
+0 −30
Original line number Diff line number Diff line
@@ -100,36 +100,6 @@ alias screenshot-cleanup='find "$HOME/Pictures" -name "Screenshot from *.png" -d
alias bell="printf '\a'"
command -v notify-send > /dev/null || alias notify-send='bell'

urlencode () {
    if [ -t 0 ]
    then
        echo "$@" | urlencode
    else
        python3 -c '
from sys import stdin
from urllib.parse import quote_plus
for line in stdin.readlines():
    print(quote_plus(line.strip()))
'
    fi
}

# shellcheck disable=SC2120
urldecode () {
    if [ -t 0 ]
    then
        # shellcheck disable=SC2119
        echo "$@" | urldecode
    else
        python3 -c '
from sys import stdin
from urllib.parse import unquote_plus
for line in stdin.readlines():
    print(unquote_plus(line.strip()))
'
    fi
}

monitor () {
    if eval "$@"
    then
+8 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
from fileinput import input
from urllib.parse import unquote_plus as unquote


if __name__ == '__main__':
    for line in input():
        print(unquote(line.strip()))
+8 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
from fileinput import input
from urllib.parse import quote_plus as quote


if __name__ == '__main__':
    for line in input():
        print(quote(line.strip()))