为了方便在BBEdit里修改文本,记录几个常用的Text Filters。
Base64 转码
#!/bin/bash
#
# Base64 Decode
# https://gist.github.com/levigroker/aacf13e1d3f88403df214542c05483b4
#
# A BBEdit Text Filter script to take textual input and produce Base64 decoded text of the
# same.
# See https://www.bbeditextras.org/text-filters/
# Levi Brown
# @levigroker
# levigroker@gmail.com
# 2022-01-07
##
IN=$(tee)
OUT=$(echo -n "$IN" | base64 --decode)
echo -n "${OUT}"
#!/bin/bash
#
# Base64 Encode
# https://gist.github.com/levigroker/cd252cc656234dd8b19bfd4d96255a5c
#
# A BBEdit Text Filter script to take textual input and produce Base64 encoded text of the
# same.
# See https://www.bbeditextras.org/text-filters/
# Levi Brown
# @levigroker
# levigroker@gmail.com
# 2022-01-07
##
IN=$(tee)
OUT=$(echo -n "$IN" | base64)
echo -n "${OUT}"
URL 转码
早先版本来自
Levi Brown
,但是不想额外安装php
,就改为使用Python
转码。
#!/bin/bash
#
# URL Decode
#
# A BBEdit Text Filter script to take textual input and produce URL decoded text of the same with Python.
# See https://www.bbeditextras.org/text-filters/
# Gaowen Kong
# kongaowen@gmail.com
# 2024/04/24
##
IN=$(tee)
CMD="echo urldecode('${IN}');"
OUT=$(echo -n "${IN}" |python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));")
echo -n "${OUT}"
#!/bin/bash
#
# URL Encode
# https://gist.github.com/levigroker/36525010ba0bce15450c89fe6a5f36b1
#
# A BBEdit Text Filter script to take textual input and produce URL encoded text of the same with Python.
# See https://www.bbeditextras.org/text-filters/
# Gaowen Kong
# kongaowen@gmail.com
# 2024/04/24
##
IN=$(tee)
CMD="echo urldecode('${IN}');"
OUT=$(echo -n "${IN}" |python3 -c "import sys; from urllib.parse import quote; print(quote(sys.stdin.read()));")
echo -n "${OUT}"