From 7811f4e088e4beeae8d9aac6063e00b3df77cdd0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 13 Jun 2019 14:13:32 +1200 Subject: Spruce up and comment on ext-counting shell --- vim/vimrc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 5bb0602d..4dca01c5 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -888,19 +888,27 @@ set wildmode=list:longest,full " giving patterns for the top 100 alphanumeric extensions for files from the " running user's home directory: " -" $ find "$HOME" ! -type d -name '*.?*' -exec \ +" $ (LC_ALL=C find "$HOME" ! -type d -name '*.?*' -exec \ " sh -c 'for fn ; do " ext=${fn##*.} " case $ext in -" *[![:alnum:]]*) continue ;; -" ?*) printf "%s\n" "$ext" ;; +" (*[![:alnum:]]*) continue ;; +" (?*) printf "%s\n" "$ext" ;; " esac " done' _ {} + | -" tr '[:upper:]' '[:lower:]' | sort | uniq -c | -" sort -k1,1nr | awk 'NR <= 100 {print "*." $2}' +" tr '[[:upper:]]' '[[:lower:]]' | sort | uniq -c | +" sort -k1,1nr | awk 'NR <= 100 {print "*." $2}') " " I turned out to have rather a lot of .html and .vim files. " +" If you're scoffing at that and thinking "I could write a much simpler one", +" please do so, and send it to me at to have yours put +" in here instead, with appropriate credit. Don't forget to handle more than +" ARG_MAX files, include filenames with newlines, and that the -z or -0 null +" separator extensions are not standardised in POSIX. +" +" +" " It's tempting to put the list of patterns here into a separate file--or at " least into a more readily editable intermediate list variable--rather than " the minor maintenance hassle it presently constitutes in this compact form. -- cgit v1.2.3