Fixed a bug in whatwhen()' help output
[grml-etc-core.git] / etc / zsh / zshrc
index 3f53ec3..55268d0 100644 (file)
@@ -3514,17 +3514,25 @@ regcheck() {
     pcre_match $2 && echo "regex matches" || echo "regex does not match"
 }
 
+#f5# List files which have been accessed within the last {\it n} days, {\it n} defaults to 1
+accessed() {
+    emulate -L zsh
+    print -l -- *(a-${1:-1})
+}
+
 #f5# List files which have been changed within the last {\it n} days, {\it n} defaults to 1
 changed() {
     emulate -L zsh
-    print -l *(c-${1:-1})
+    print -l -- *(c-${1:-1})
 }
 
 #f5# List files which have been modified within the last {\it n} days, {\it n} defaults to 1
-new() {
+modified() {
     emulate -L zsh
-    print -l *(m-${1:-1})
+    print -l -- *(m-${1:-1})
 }
+# modified() was named new() in earlier versions, add an alias for backwards compatibility
+check_com new || alias new=modified
 
 #f5# Grep in history
 greph() {
@@ -4121,41 +4129,46 @@ if check_com -c highlight ; then
     compdef _hl_complete hl
 fi
 
+# TODO:
+# Rewrite this by either using tinyurl.com's API
+# or using another shortening service to comply with
+# tinyurl.com's policy.
+#
 # Create small urls via http://tinyurl.com using wget(1).
-function zurl() {
-    emulate -L zsh
-    [[ -z $1 ]] && { print "USAGE: zurl <URL>" ; return 1 }
-
-    local PN url tiny grabber search result preview
-    PN=$0
-    url=$1
-#   Check existence of given URL with the help of ping(1).
-#   N.B. ping(1) only works without an eventual given protocol.
-    ping -c 1 ${${url#(ftp|http)://}%%/*} >& /dev/null || \
-        read -q "?Given host ${${url#http://*/}%/*} is not reachable by pinging. Proceed anyway? [y|n] "
-
-    if (( $? == 0 )) ; then
-#           Prepend 'http://' to given URL where necessary for later output.
-            [[ ${url} != http(s|)://* ]] && url='http://'${url}
-            tiny='http://tinyurl.com/create.php?url='
-            if check_com -c wget ; then
-                grabber='wget -O- -o/dev/null'
-            else
-                print "wget is not available, but mandatory for ${PN}. Aborting."
-            fi
-#           Looking for i.e.`copy('http://tinyurl.com/7efkze')' in TinyURL's HTML code.
-            search='copy\(?http://tinyurl.com/[[:alnum:]]##*'
-            result=${(M)${${${(f)"$(${=grabber} ${tiny}${url})"}[(fr)${search}*]}//[()\';]/}%%http:*}
-#           TinyURL provides the rather new feature preview for more confidence. <http://tinyurl.com/preview.php>
-            preview='http://preview.'${result#http://}
-
-            printf '%s\n\n' "${PN} - Shrinking long URLs via webservice TinyURL <http://tinyurl.com>."
-            printf '%s\t%s\n\n' 'Given URL:' ${url}
-            printf '%s\t%s\n\t\t%s\n' 'TinyURL:' ${result} ${preview}
-    else
-        return 1
-    fi
-}
+#function zurl() {
+#    emulate -L zsh
+#    [[ -z $1 ]] && { print "USAGE: zurl <URL>" ; return 1 }
+#
+#    local PN url tiny grabber search result preview
+#    PN=$0
+#    url=$1
+##   Check existence of given URL with the help of ping(1).
+##   N.B. ping(1) only works without an eventual given protocol.
+#    ping -c 1 ${${url#(ftp|http)://}%%/*} >& /dev/null || \
+#        read -q "?Given host ${${url#http://*/}%/*} is not reachable by pinging. Proceed anyway? [y|n] "
+#
+#    if (( $? == 0 )) ; then
+##           Prepend 'http://' to given URL where necessary for later output.
+#            [[ ${url} != http(s|)://* ]] && url='http://'${url}
+#            tiny='http://tinyurl.com/create.php?url='
+#            if check_com -c wget ; then
+#                grabber='wget -O- -o/dev/null'
+#            else
+#                print "wget is not available, but mandatory for ${PN}. Aborting."
+#            fi
+##           Looking for i.e.`copy('http://tinyurl.com/7efkze')' in TinyURL's HTML code.
+#            search='copy\(?http://tinyurl.com/[[:alnum:]]##*'
+#            result=${(M)${${${(f)"$(${=grabber} ${tiny}${url})"}[(fr)${search}*]}//[()\';]/}%%http:*}
+##           TinyURL provides the rather new feature preview for more confidence. <http://tinyurl.com/preview.php>
+#            preview='http://preview.'${result#http://}
+#
+#            printf '%s\n\n' "${PN} - Shrinking long URLs via webservice TinyURL <http://tinyurl.com>."
+#            printf '%s\t%s\n\n' 'Given URL:' ${url}
+#            printf '%s\t%s\n\t\t%s\n' 'TinyURL:' ${result} ${preview}
+#    else
+#        return 1
+#    fi
+#}
 
 #f2# Print a specific line of file(s).
 linenr () {
@@ -4188,7 +4201,7 @@ whatwhen()  {
     emulate -L zsh
     local usage help ident format_l format_s first_char remain first last
     usage='USAGE: whatwhen [options] <searchstring> <search range>'
-    help='Use' \`'whatwhen -h'\'' for further explanations.'
+    help='Use `whatwhen -h'\'' for further explanations.'
     ident=${(l,${#${:-Usage: }},, ,)}
     format_l="${ident}%s\t\t\t%s\n"
     format_s="${format_l//(\\t)##/\\t}"