zsh-users
 help / color / mirror / code / Atom feed
* Can we have an additional output option for setopt?
@ 2012-01-18 20:20 Larry Schrof
  2012-01-18 21:08 ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Larry Schrof @ 2012-01-18 20:20 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]

I can appreciate the logic that goes into displaying the 'no' prefix in the output of setopt. (As it pertains to defaults and minimizing the amount of output.)

However, I find myself often wanting to see every option listed by raw name, along with it's current state. And I don't care about the defaults; I'd like to see the list without the 'no' prefixes polluting the output.

I originally set KSH_OPTION_PRINT, and got this as the first few lines of output:

noaliases             off
allexport             off
noalwayslastprompt    off
alwaystoend           on
...

This is CLOSE to what I want, but what I really would like to see instead is this:

aliases               on
allexport             off
alwayslastprompt      on
alwaystoend           on
...

Could we consider adding in this functionality? I'll leave it up to the devs to decide how this functionality gets turned on and off, but part of me is thinking it should maybe be an option, perhaps called 'OPTION_PRINT_VERBOSE' or something like that...




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can we have an additional output option for setopt?
  2012-01-18 20:20 Can we have an additional output option for setopt? Larry Schrof
@ 2012-01-18 21:08 ` Mikael Magnusson
  2012-01-19 10:04   ` Peter Stephenson
  2012-01-19 17:41   ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Mikael Magnusson @ 2012-01-18 21:08 UTC (permalink / raw)
  To: Larry Schrof; +Cc: zsh-users

On 18 January 2012 21:20, Larry Schrof <larrys@fb.com> wrote:
> I can appreciate the logic that goes into displaying the 'no' prefix in the output of setopt. (As it pertains to defaults and minimizing the amount of output.)
>
> However, I find myself often wanting to see every option listed by raw name, along with it's current state. And I don't care about the defaults; I'd like to see the list without the 'no' prefixes polluting the output.
>
> I originally set KSH_OPTION_PRINT, and got this as the first few lines of output:
>
> noaliases             off
> allexport             off
> noalwayslastprompt    off
> alwaystoend           on
> ...
>
> This is CLOSE to what I want, but what I really would like to see instead is this:
>
> aliases               on
> allexport             off
> alwayslastprompt      on
> alwaystoend           on
> ...
>
> Could we consider adding in this functionality? I'll leave it up to the devs to decide how this functionality gets turned on and off, but part of me is thinking it should maybe be an option, perhaps called 'OPTION_PRINT_VERBOSE' or something like that...

printf '%s\t%s\n' ${(kv)options


-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can we have an additional output option for setopt?
  2012-01-18 21:08 ` Mikael Magnusson
@ 2012-01-19 10:04   ` Peter Stephenson
  2012-01-19 19:28     ` Greg Klanderman
  2012-01-19 17:41   ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2012-01-19 10:04 UTC (permalink / raw)
  To: zsh-users

On Wed, 18 Jan 2012 22:08:43 +0100
Mikael Magnusson <mikachu@gmail.com> wrote:
> printf '%s\t%s\n' ${(kv)options}

Here's one way of getting setopt to do that (a bit more neatly).

setopt() {
  if (( $# )); then
    typeset -ga global_setopt_args
    global_setopt_args=("$@")
    trap 'builtin setopt "${(@)global_setopt_args}"' EXIT
  else
    local k
    zmodload -i zsh/parameter

    for k in ${(ok)options}; do
      printf "%-20s\t%s\n" $k ${options[$k]}
    done
  fi
}

It's a little hairy because running setopt as a function is unnatural
owing to the fact that certain options (xtrace in particular) always
have function scope.  Alternatively, just use a separate function.

showoptions() {
  local k
  zmodload -i zsh/parameter

  for k in ${(ok)options}; do
    printf "%-20s\t%s\n" $k ${options[$k]}
  done
}

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can we have an additional output option for setopt?
  2012-01-18 21:08 ` Mikael Magnusson
  2012-01-19 10:04   ` Peter Stephenson
@ 2012-01-19 17:41   ` Bart Schaefer
  2012-01-19 18:37     ` Larry Schrof
  1 sibling, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2012-01-19 17:41 UTC (permalink / raw)
  To: zsh-users

On Jan 18, 10:08pm, Mikael Magnusson wrote:
}
} printf '%s\t%s\n' ${(kv)options

Even better:

printf '%-20s %s\n' ${(kv)options}

-- 
Barton E. Schaefer


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can we have an additional output option for setopt?
  2012-01-19 17:41   ` Bart Schaefer
@ 2012-01-19 18:37     ` Larry Schrof
  0 siblings, 0 replies; 6+ messages in thread
From: Larry Schrof @ 2012-01-19 18:37 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users

Thanks everyone - this has all been helpful, and just what I need.

On 1/19/12 9:41 AM, "Bart Schaefer" <schaefer@brasslantern.com> wrote:

>On Jan 18, 10:08pm, Mikael Magnusson wrote:
>}
>} printf '%s\t%s\n' ${(kv)options
>
>Even better:
>
>printf '%-20s %s\n' ${(kv)options}
>
>-- 
>Barton E. Schaefer


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Can we have an additional output option for setopt?
  2012-01-19 10:04   ` Peter Stephenson
@ 2012-01-19 19:28     ` Greg Klanderman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Klanderman @ 2012-01-19 19:28 UTC (permalink / raw)
  To: zsh-users


>>>>> On January 19, 2012 Peter Stephenson <Peter.Stephenson@csr.com> wrote:

> showoptions() {
>   local k
>   zmodload -i zsh/parameter
>
>   for k in ${(ok)options}; do
>     printf "%-20s\t%s\n" $k ${options[$k]}
>   done
> }

I have almost exactly that function, except I do

   for k in ${@:-${(ok)options}}; do

so I can optionally specify a list of options on the
command line, and set up completion appropriately.

Greg


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-19 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-18 20:20 Can we have an additional output option for setopt? Larry Schrof
2012-01-18 21:08 ` Mikael Magnusson
2012-01-19 10:04   ` Peter Stephenson
2012-01-19 19:28     ` Greg Klanderman
2012-01-19 17:41   ` Bart Schaefer
2012-01-19 18:37     ` Larry Schrof

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).