summaryrefslogtreecommitdiff
path: root/zsh/Functions
diff options
context:
space:
mode:
authorNick Shipp <nick@shipp.ninja>2017-02-14 08:41:16 -0500
committerNick Shipp <nick@shipp.ninja>2017-02-14 08:41:16 -0500
commit24a605577c8e09a75f8f717f9df1bdc6c8dd8ec3 (patch)
tree794db72af4e1ddf41cff2d1f6371b27103562d69 /zsh/Functions
initial commit
Diffstat (limited to 'zsh/Functions')
-rw-r--r--zsh/Functions/_uri58
-rw-r--r--zsh/Functions/memoize11
2 files changed, 69 insertions, 0 deletions
diff --git a/zsh/Functions/_uri b/zsh/Functions/_uri
new file mode 100644
index 0000000..40d1811
--- /dev/null
+++ b/zsh/Functions/_uri
@@ -0,0 +1,58 @@
+compdef uri
+
+local uri_commands
+uri_commands=( \
+ create change scheme has_recognized_scheme \
+ opaque path fragment as_string as_iri canonical \
+ secure authority path path_query query userinfo host \
+ ihost port host_port default_port \
+ media_type data \
+ file dir \
+ user password \
+ gopher_type selector search string \
+ dn attributes scope filter extensions \
+ un_path \
+ to headers \
+ group message \
+ nid nss )
+
+_arguments \
+ '1: :->cmds' \
+ '*:: :->args'
+
+
+case $state in
+ (cmds)
+ _values 'uri commands' $uri_commands
+ ;;
+ (args)
+ _arguments \
+ '--scheme=-:' \
+ '--path=-:' \
+ '--opaque=-[Opaque portion of URI (between scheme: and fragment)]:' \
+ '--fragment=-[Escaped URI fragment (#foo)]:' \
+ '--authority=-:' \
+ '--query=-[Escaped query component]:' \
+ '--userinfo=-[e.g. username:password]:' \
+ '--port=-:' \
+ '--host_port=-[host:port]:' \
+ '--media_type=-[Media type for data: URIs]:' \
+ '--data=-[Data for data: URIs]:' \
+ '--file=-[File for file:, ftp:, etc.]:' \
+ '--gopher_type=-:' \
+ '--selector=-[Gopher selector]:' \
+ '--search=-[Gopher query]:' \
+ '--string=-[Gopher string]:' \
+ '--dn=-[LDAP DN]' \
+ '--attributes=-[LDAP attributes]' \
+ '--scope=-[LDAP search scope]:' \
+ '--extensions=-[LDAP extensions]:' \
+ '--un_path=-[Local socket path for ldapi]:' \
+ '--to=-[Address for mailto:]:' \
+ '--headers=-[mailto: headers]:' \
+ '--group=-[Newsgroup]:' \
+ '--message=-[Newsgroup message]:' \
+ '--nid=-[Namespace identifier for urn:]:' \
+ '--nss=-[Namespace-specific string for urn:]:'
+ ;;
+esac
diff --git a/zsh/Functions/memoize b/zsh/Functions/memoize
new file mode 100644
index 0000000..c58e65d
--- /dev/null
+++ b/zsh/Functions/memoize
@@ -0,0 +1,11 @@
+if ((! $+MEMOIZE)) {
+ declare -Ag MEMOIZE
+}
+
+if (($+MEMOIZE[$*])) {
+ printf '%s' "$MEMOIZE[$*]"
+ return
+}
+
+MEMOIZE[$*]=$(eval $*)
+printf '%s' "$MEMOIZE[$*]"