From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25723 invoked from network); 28 Jan 2023 00:13:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Jan 2023 00:13:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674864806; b=aXqvPs7HjMXFvIsH4RjSrHJ41jaiNL2HGpj9PzxMKQNDC1IQNOewEtCzh+36IyxnrIFQUeM/MA qdJ2xTjxl3TMsJV4nbDbzXN4aVZtaVSl4DwJe9vTqR8WIPW2gx82y2iWGzah8kfgVURQkaUSpx n0yTfCybeKzfOB+4jyqD+9FkzaJe/zVlFhEJo4HXaMB8r+CUHk5ftcTJcoX3YLosEOYAGB65zU eFntiVZkbQgDbdBm/ffMcZhkTlbPvyHBSlrMDDo2H9BckFgQ2inSI2mwpDIeP7UkkpShHgW2Do rESLkP5bn9d85yYxQ7CFI9JRL1W2CNTSpkoiZULJhdF3tA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1674864806; bh=lUvP3EMRYKTB6kj4ul1ivwwXPPld3bvv4AVnyYrQjL4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=YvLqjgI8eBD/Md+nkSet09AJFFhYlUsa3noYfonBrpz34Stxh1x+kNcrgdaPCXjcCRlr/eyhKL Th4uU/udI9ZbUp/7dTMUI2B8VnFoZdqxPEXHd9VvV4H4Lt7oKQJw4lJxtc/0fiu1svbO6gqZMK shmkIZUAHYOT4guKz+gio71Hr0TRfTlE2WE7B20C2JcauJ46UHUYjZ7WqhT70ah/eUBTKf1hg+ gFGFWBSFLDgOHR7PBGoefIYrCLUudMi4KI9lBm3eHsqFmqZyXuLLelOY240PYkbLT3Q97Vd7nM Hr+9OIFuWPQJ1ce8ISBCZ+6FeCIpChPd7AWeNDUzrLKEHA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-transfer-encoding: Content-type:In-reply-to:From:References:To:Subject:MIME-version:Date: Message-id:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nAtgEMpm0bgAAMHxz8tjCkJypdrTmxKLqS2f62cGnuk=; b=J6oX9O4P0CCmS994mtmoeWx7m+ 619uFnm8lzasVCT3mg4KxStklGc1TzcAK9v0t75vuIzUDpjqcKgGIqT6xz9SO7X0aggtBSxCMJSCG w+XBQiSHGed4UOgALY8ebehRsx+7z9zKe88mDnZCHmKpO21fp+PbxG12VI4gjsHuj6xKqytf5O23E vFJksI9w+uGdUzraBawHCLmAtt4BZfJxQZQxacL/n5cgch6P6rmjgbYVdna7x0JVKsaZEv2EPeF76 fkVWwzZgmd6zPCnLOmdOR0GWIeInR74ceguCiHemCMQBIZO8iwaQXScEIj65htoWNqJz+VhUQY4Pa ATHxj09Q==; Received: by zero.zsh.org with local id 1pLYqT-000GEP-Hs; Sat, 28 Jan 2023 00:13:25 +0000 Authentication-Results: zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none Received: from mta03.eastlink.ca ([24.224.136.9]:60803) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1pLYph-000FW5-4D; Sat, 28 Jan 2023 00:12:38 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta03.eastlink.ca ([24.224.136.9]) with ESMTPS id <0RP6004EQ4II0C40@mta03.eastlink.ca> for zsh-users@zsh.org; Fri, 27 Jan 2023 20:12:36 -0400 (AST) Received: from [192.168.0.4] (host-24-207-18-108.public.eastlink.ca [24.207.18.108]) by csp01.eastlink.ca ([71.7.199.166]) with ESMTPSA id LYpfpi49t6z6sLYpfpfg3V (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Fri, 27 Jan 2023 20:12:35 -0400 X-Authority-Analysis: v=2.4 cv=bOzQYtyZ c=1 sm=1 tr=0 ts=63d46873 a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=j1uF8P4dAAAA:8 a=P5oHIsD8f9Qhnsv5RJAA:9 a=QEXdDO2ut3YA:10 a=-5XtbtpHebCQafhMkRpj:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddvjedgudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepiedtjeffvefgtdehgefgteekueeggeeitedutddvvdduteetffdvveelgfeukedunecukfhppedvgedrvddtjedrudekrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrddukedruddtkedphhgvlhhopegludelvddrudeikedrtddrgegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Message-id: Date: Fri, 27 Jan 2023 16:12:35 -0800 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: path PATH Content-language: en-US To: zsh-users@zsh.org References: <0dc71450-d082-93da-52f8-d4e6b97199af@eastlink.ca> <2f2c3ae4-ca4e-8101-5934-9eb493ff61cd@eastlink.ca> <30292878-d596-75cb-8dc3-f64f9b82a44d@eastlink.ca> <3ea702de-f818-adbb-c55b-e585f8deb10f@eastlink.ca> <1a232406-ad76-b661-496b-974ddf8e67fe@ckhb.org> From: Ray Andrews In-reply-to: <1a232406-ad76-b661-496b-974ddf8e67fe@ckhb.org> Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28835 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 2023-01-27 15:45, scowles@ckhb.org wrote: > > as a lurker on the list, i am very grateful that you, ray, persevered > through this thread.  if dp(){} has changed since yesterday, would you > mind posting your latest version? > The guts of it are almost exactly as Bart left it, but my version tarts it up a little bit: A few notes: 'infomsg' is just a colored message, 'echo' is fine. ${cyn} is just the color code for cyan, and ${nrm} is the code for 'normal'.  I like colored output.  As I have it, the accumulated output goes to a variable instead of printing directly but the old code is there too.  And I've shortened the type-strings to single letters but that's easy to cut out if you want.  Oh, and I also truncate at screen width but that's also easy to cut out.  I Don't need to see those huge variables full length: function v () # For 'variables'. {     [[ "$1" = '-h' || "$1" = '-s' ]] && \     {     infomsg " List attributes and values of all variables indicated by FILTER. v ,CSsp [FILTER] v ,C: SENS: (if FILTER is given). v ,S: Show only if the value is not hidden. v ,s: Show only if the value IS hidden. v ,p: Plain, no color, this is good when the output needs to be sent to a file. FILTER: if given, is a pattern of variable names.  If wildcards are given then the argument must be quoted to avoid expansion by the shell. TYPES: These are condensed from the detailed information you can see like this: '$ print ${(t)path}'.  Basic types are capitalized, modifiers are in lower case: S: An ordinary scalar (not an integer or float). I: An integer. F: A float ('typeset -F:' decimal display or 'typeset -E': scientific display). A: A normal array. H: An associative array or 'association' or 'hash' (always 'hideval' as well). e: The variable has been exported to the environment and is thus persistent within that terminal -- it will be inherited by subshells. l: The variable is local to the running function. t: The variable is 'tied' to another variable (see docs: 'typeset -T'). s: The variable is special to the shell. r: The variable is read-only (this often goes with 'special'). v: 'hideval': the value of the variable will be hidden -- there are things we really don't want to see, like lists of color codes.  This tends to go with 'special' and 'hide'. h: Hide: Used with 'special' (see docs: 'typeset -h'). u: Unique: ?? ?: Undefined: For autoloaded parameters not yet loaded (whatever that means). " return     }     local ccolored=( sed -r "s/^(.{6})([^ = ]*)/\1${cyn}\2${nrm}/" )     local hhidden=( )     local case='(#i)'     local width=$(( COLUMNS - 5 ))     local line=     typeset -ga VARIABLES=()     if [[ ${1:0:1} == ',' ]]; then     for ((i=1; i < ${#1}; i++)); do     case ${1:$i:1} in         C ) case= ;; # Enable case sensitive.         p ) ccolored= ;; # 'plain': no color.         S ) hhidden=( grep -v ' = !hidden!' ) ;;    # Show only if a value is set.         s ) hhidden=( grep ' = !hidden!' ) ;; # Show only if a value is NOT set.         * ) errormsg "No such switch \",${1:$i:1}\""; return 1 ;;         esac     done     shift     fi      # End: process ',' switches.     # If a capital letter is given then force case sensitivity:     [[ $@ == *[[:upper:]]* ]] && case=     # Default is all params:     [ ! "$@" ] && set 1 '*'     set -- ${(ok)parameters[(I)${case}${~${(j.|.)@}}]}     while ((ARGC)); do         # Type eg: 'scalar ' #        print -rn -- "${parameters[$1]} "         line+="${parameters[$1]} "         if [[ -${parameters[$1]}- = *-hideval-* ]]         then             # Append name and '=-hidden-'             # If param is hidden, typeset won't show anything so use this: #            print -r -- ${(q-)1}             line+="${(q-)1}=!hidden!"         else             # Append name and value eg: 'ZSH_VERSION=5.8': #            typeset -m -- ${(b)1}             line+=$( typeset -m -- ${(b)1} )         fi     VARIABLES+="$line"     line=     shift     done     echo     [ ! "$VARIABLES" ] && warningmsg "Nothing found" && return 1 print -rl -- $VARIABLES | sed \ -re "s/(^[^ ]*) ([^=]*)=(.*)/\1   \2 = \3/" \  -e "s/scalar[ |-]/S/" \  -e "s/integer[ |-]/I/" \  -e "s/float[ |-]/F/" \  -e "s/array[ |-]/A/" \  -e "s/association[ |-]/H/" \  -e "s/export[ |-]/e/" \  -e "s/local[ |-]/l/" \  -e "s/special[ |-]/s/" \  -e "s/readonly[ |-]/r/" \  -e "s/hideval[ |-]/v/" \  -e "s/hide[ |-]/h/" \  -e "s/tied[ |-]/t/" \  -e "s/unique[ |-]/u/" \  -e "s/undefined[ |-]/?/" \  -e "s/^([^ ]*)/\1     /" \  -e "s/^(.{6}) */\1/" \  -e "s/^(.{1,${width}}).*/\1/" \  -e "s/^(.{$width})/\1 .../" \  | ${ccolored:-cat} | ${hhidden:-cat} } # END: v() allvars () {     # Name and type:     print -l -- "\n${cyn}ALL VARIABLES AND THEIR TYPES:${nrm} \n"     printf "%-25s %s\n" ${(kv)parameters} | sort     # Types only: #    printf "%s\n" ${(v)parameters} | sort } nullvars () {     # emulate -L zsh -o extendedglob     nnullvars=()     for name in ${(k)parameters}; do         if [[ -z ${(P)name} ]]; then #        print -r -- $name             nnullvars+="$name"         fi     done     print -l -- "\n${cyn}NULL VARIABLES:${nrm} \n"     print -l -- "$nnullvars[@]" | sort } ... hope you like it!