diff --git a/.config/fish/functions/uri-path.fish b/.config/fish/functions/uri-path.fish new file mode 100644 index 00000000..ae0a5742 --- /dev/null +++ b/.config/fish/functions/uri-path.fish @@ -0,0 +1,18 @@ +function uri-path + argparse h/help r/reverse -- $argv + if set -q _flag_h + echo "Convert a file URI to a Path." + echo "-h/--help for help." + echo "-r/--reverse to convert a path to URI." + end + if test -z "$argv[1]" + read -f input + else + set input $argv[1] + end + if not set -q _flag_r + string unescape --style=url "$input" | string replace -a ' ' '\\ ' | string replace 'file://' '' + else + printf 'file://%s\n' (string replace '\\ ' ' ' "$input" | string escape --style=url) + end +end