3 # Input filters are useful also for non interactive shells (e.g. from vim), so
4 # expand them unconditionally.
5 shopt -s expand_aliases
7 if command -v php &> /dev/null;
9 # Encode/decode HTML special characters.
10 alias htmlencode="php -r 'echo htmlspecialchars(file_get_contents(\"php://stdin\"), ENT_COMPAT | ENT_XHTML, \"UTF-8\", false);'"
11 alias htmldecode="php -r 'echo htmlspecialchars_decode(file_get_contents(\"php://stdin\"), ENT_COMPAT | ENT_XHTML);'"
14 # Decode URL encoded strings.
15 # From https://stackoverflow.com/questions/6250698/how-to-decode-url-encoded-string-in-shell
16 urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
18 # Probably a more robust one.
19 #alias urldecode='python -c "import sys, urllib as ul; print ul.unquote(sys.stdin.read());"'