zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH v2 0/1] Useful default of HISTSIZE
@ 2022-09-06 19:50 Felipe Contreras
  2022-09-06 19:50 ` [PATCH v2 1/1] Increase default HISTSIZE to 1000 Felipe Contreras
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Contreras @ 2022-09-06 19:50 UTC (permalink / raw)
  To: zsh-workers
  Cc: Peter Stephenson, Daniel Shahaf, Bart Schaefer, Felipe Contreras

If we are going to recommend to most new users to set HISTSIZE to 1000,
then it makes more sense to set that as default instead of 30. The less
options we bother new users with, the better.

We are not in 1990 anymore (when in fact the default was 128).

Felipe Contreras (1):
  Increase default HISTSIZE to 1000

 Etc/FAQ.yo                            | 17 +++++++----------
 Functions/Newuser/zsh-newuser-install |  3 +--
 StartupFiles/zshrc                    |  2 +-
 configure.ac                          |  2 +-
 4 files changed, 10 insertions(+), 14 deletions(-)

Range-diff against v1:
1:  95f64c276 < -:  --------- Set SAVEHIST to $HISTSIZE by default
2:  747d23c8c ! 1:  edef19cbd Increase default HISTSIZE to 1000
    @@ Metadata
      ## Commit message ##
         Increase default HISTSIZE to 1000
     
    -    If the default is sensible it's not necessary for the user to change it.
    +    If the default is sensible then it's not necessary for the user to
    +    change it.
    +
    +    Moreover, the FAQ is wrong: it says it's necessary to set HISTSIZE for
    +    the history to saved, but it isn't. HISTSIZE by default is 30 and that's
    +    enough to save the history, although not very useful. Therefore only
    +    *two* variables need to be set.
    +
    +    This is even more clear after we remove HISTSIZE from the example, but
    +    then the text "The simplest possibility is to set it to the same as
    +    tt($HISTSIZE) as above" becomes problematic as the value of HISTSIZE is
    +    not readily available.
    +
    +    The user doesn't need to know the value of HISTSIZE though, she can
    +    simply use $HISTSIZE instead.
    +
    +    This has the advantage that if HISTSIZE is increased again in the future
    +    (as it probably should because most modern computers can easily afford
    +    orders of magnitude more), nobody needs to worry about SAVEHIST (neither
    +    in the FAQ, zsh-newuser-install, or existing zshrc files).
    +
    +    Also, semantically makes more sense and carries less cognitive load.
     
         Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
     
    @@ Etc/FAQ.yo: work?)
        verb(
     -    HISTSIZE=200
          HISTFILE=~/.zsh_history
    -     SAVEHIST=$HISTSIZE
    -   )
    +-    SAVEHIST=200
    +-  )
     -  tt($HISTSIZE) tells the shell how many lines to keep internally,
     -  tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
     -  the easiest one to forget, tells it how many to write out.  The
     -  simplest possibility is to set it to the same as tt($HISTSIZE) as
     -  above.  There are also various options affecting history; see the
     -  manual.
    ++    SAVEHIST=$HISTSIZE
    ++  )
     +  tt($HISTFILE) tells the shell where to write the history, and tt($SAVEHIST)
     +  tells it how many lines to write out.  The simplest possibility is to set it
     +  to the same as tt($HISTSIZE) as above.  There are also various options
    @@ Functions/Newuser/zsh-newuser-install: ${(F)unparsed}
        __zni_apply_defaults -p \
     -    HISTSIZE 1000 "Number of lines of history kept within the shell." \
          HISTFILE $zdmsg/.histfile "File where history is saved." \
    -     SAVEHIST \$HISTSIZE "Number of lines of history to save to \$HISTFILE."
    +-    SAVEHIST 1000 "Number of lines of history to save to \$HISTFILE."
    ++    SAVEHIST \$HISTSIZE "Number of lines of history to save to \$HISTFILE."
      
    +   if __zni_display_and_edit "History configuration"; then
    +     install_state[history]="Unsaved changes"
     
      ## StartupFiles/zshrc ##
     @@ StartupFiles/zshrc: export HELPDIR=/usr/share/zsh/$ZSH_VERSION/help  # directory for run-help functi
-- 
2.37.2.351.g9bf691b78c.dirty



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

* [PATCH v2 1/1] Increase default HISTSIZE to 1000
  2022-09-06 19:50 [PATCH v2 0/1] Useful default of HISTSIZE Felipe Contreras
@ 2022-09-06 19:50 ` Felipe Contreras
  2022-09-06 20:15   ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Contreras @ 2022-09-06 19:50 UTC (permalink / raw)
  To: zsh-workers
  Cc: Peter Stephenson, Daniel Shahaf, Bart Schaefer, Felipe Contreras

If the default is sensible then it's not necessary for the user to
change it.

Moreover, the FAQ is wrong: it says it's necessary to set HISTSIZE for
the history to saved, but it isn't. HISTSIZE by default is 30 and that's
enough to save the history, although not very useful. Therefore only
*two* variables need to be set.

This is even more clear after we remove HISTSIZE from the example, but
then the text "The simplest possibility is to set it to the same as
tt($HISTSIZE) as above" becomes problematic as the value of HISTSIZE is
not readily available.

The user doesn't need to know the value of HISTSIZE though, she can
simply use $HISTSIZE instead.

This has the advantage that if HISTSIZE is increased again in the future
(as it probably should because most modern computers can easily afford
orders of magnitude more), nobody needs to worry about SAVEHIST (neither
in the FAQ, zsh-newuser-install, or existing zshrc files).

Also, semantically makes more sense and carries less cognitive load.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Etc/FAQ.yo                            | 17 +++++++----------
 Functions/Newuser/zsh-newuser-install |  3 +--
 StartupFiles/zshrc                    |  2 +-
 configure.ac                          |  2 +-
 4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index 8c795685a..4c058c363 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -1626,19 +1626,16 @@ work?)
 sect(Why is my history not being saved?)
 label(321)
 
-  In zsh, you need to set three variables to make sure your history is
+  In zsh, you need to set two variables to make sure your history is
   written out when the shell exits.  For example,
   verb(
-    HISTSIZE=200
     HISTFILE=~/.zsh_history
-    SAVEHIST=200
-  )
-  tt($HISTSIZE) tells the shell how many lines to keep internally,
-  tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
-  the easiest one to forget, tells it how many to write out.  The
-  simplest possibility is to set it to the same as tt($HISTSIZE) as
-  above.  There are also various options affecting history; see the
-  manual.
+    SAVEHIST=$HISTSIZE
+  )
+  tt($HISTFILE) tells the shell where to write the history, and tt($SAVEHIST)
+  tells it how many lines to write out.  The simplest possibility is to set it
+  to the same as tt($HISTSIZE) as above.  There are also various options
+  affecting history; see the manual.
 
 sect(How do I get a variable's value to be evaluated as another variable?)
 
diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install
index 9e911d07c..46b1639c5 100644
--- a/Functions/Newuser/zsh-newuser-install
+++ b/Functions/Newuser/zsh-newuser-install
@@ -790,9 +790,8 @@ ${(F)unparsed}
 
 __zni_history_config() {
   __zni_apply_defaults -p \
-    HISTSIZE 1000 "Number of lines of history kept within the shell." \
     HISTFILE $zdmsg/.histfile "File where history is saved." \
-    SAVEHIST 1000 "Number of lines of history to save to \$HISTFILE."
+    SAVEHIST \$HISTSIZE "Number of lines of history to save to \$HISTFILE."
 
   if __zni_display_and_edit "History configuration"; then
     install_state[history]="Unsaved changes"
diff --git a/StartupFiles/zshrc b/StartupFiles/zshrc
index d4e1d03cc..f8a0233bf 100644
--- a/StartupFiles/zshrc
+++ b/StartupFiles/zshrc
@@ -79,7 +79,7 @@ export HELPDIR=/usr/share/zsh/$ZSH_VERSION/help  # directory for run-help functi
 unalias run-help && autoload -Uz run-help
 
 MAILCHECK=300
-HISTSIZE=200
+HISTSIZE=1000
 DIRSTACKSIZE=20
 
 # Watch for my friends
diff --git a/configure.ac b/configure.ac
index 890ef8dd2..6ca5c9189 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3213,7 +3213,7 @@ AH_TOP([/***** begin user configuration section *****/
 #define USE_SUSPENDED 1
  
 /* The default history buffer size in lines */
-#define DEFAULT_HISTSIZE 30
+#define DEFAULT_HISTSIZE 1000
 
 /* The default editor for the fc builtin */
 #define DEFAULT_FCEDIT "vi"
-- 
2.37.2.351.g9bf691b78c.dirty



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

* Re: [PATCH v2 1/1] Increase default HISTSIZE to 1000
  2022-09-06 19:50 ` [PATCH v2 1/1] Increase default HISTSIZE to 1000 Felipe Contreras
@ 2022-09-06 20:15   ` Mikael Magnusson
  2022-09-07  0:08     ` Felipe Contreras
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2022-09-06 20:15 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: zsh-workers, Peter Stephenson, Daniel Shahaf, Bart Schaefer

On 9/6/22, Felipe Contreras <felipe.contreras@gmail.com> wrote:
> If the default is sensible then it's not necessary for the user to
> change it.
>
> Moreover, the FAQ is wrong: it says it's necessary to set HISTSIZE for
> the history to saved, but it isn't. HISTSIZE by default is 30 and that's
> enough to save the history, although not very useful. Therefore only
> *two* variables need to be set.
>
> This is even more clear after we remove HISTSIZE from the example, but
> then the text "The simplest possibility is to set it to the same as
> tt($HISTSIZE) as above" becomes problematic as the value of HISTSIZE is
> not readily available.
>
> The user doesn't need to know the value of HISTSIZE though, she can
> simply use $HISTSIZE instead.
>
> This has the advantage that if HISTSIZE is increased again in the future
> (as it probably should because most modern computers can easily afford
> orders of magnitude more), nobody needs to worry about SAVEHIST (neither
> in the FAQ, zsh-newuser-install, or existing zshrc files).
>
> Also, semantically makes more sense and carries less cognitive load.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  Etc/FAQ.yo                            | 17 +++++++----------
>  Functions/Newuser/zsh-newuser-install |  3 +--
>  StartupFiles/zshrc                    |  2 +-
>  configure.ac                          |  2 +-
>  4 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> index 8c795685a..4c058c363 100644
> --- a/Etc/FAQ.yo
> +++ b/Etc/FAQ.yo
> @@ -1626,19 +1626,16 @@ work?)
>  sect(Why is my history not being saved?)
>  label(321)
>
> -  In zsh, you need to set three variables to make sure your history is
> +  In zsh, you need to set two variables to make sure your history is
>    written out when the shell exits.  For example,
>    verb(
> -    HISTSIZE=200
>      HISTFILE=~/.zsh_history
> -    SAVEHIST=200
> -  )
> -  tt($HISTSIZE) tells the shell how many lines to keep internally,
> -  tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
> -  the easiest one to forget, tells it how many to write out.  The
> -  simplest possibility is to set it to the same as tt($HISTSIZE) as
> -  above.  There are also various options affecting history; see the
> -  manual.
> +    SAVEHIST=$HISTSIZE
> +  )
> +  tt($HISTFILE) tells the shell where to write the history, and
> tt($SAVEHIST)
> +  tells it how many lines to write out.  The simplest possibility is to set
> it
> +  to the same as tt($HISTSIZE) as above.  There are also various options
> +  affecting history; see the manual.

NAK on the above hunk from me, making the FAQ less informative is not a goal.

>  sect(How do I get a variable's value to be evaluated as another variable?)
>
> diff --git a/Functions/Newuser/zsh-newuser-install
> b/Functions/Newuser/zsh-newuser-install
> index 9e911d07c..46b1639c5 100644
> --- a/Functions/Newuser/zsh-newuser-install
> +++ b/Functions/Newuser/zsh-newuser-install
> @@ -790,9 +790,8 @@ ${(F)unparsed}
>
>  __zni_history_config() {
>    __zni_apply_defaults -p \
> -    HISTSIZE 1000 "Number of lines of history kept within the shell." \
>      HISTFILE $zdmsg/.histfile "File where history is saved." \
> -    SAVEHIST 1000 "Number of lines of history to save to \$HISTFILE."
> +    SAVEHIST \$HISTSIZE "Number of lines of history to save to
> \$HISTFILE."
>
>    if __zni_display_and_edit "History configuration"; then
>      install_state[history]="Unsaved changes"

Ditto here for the same reason.

> diff --git a/StartupFiles/zshrc b/StartupFiles/zshrc
> index d4e1d03cc..f8a0233bf 100644
> --- a/StartupFiles/zshrc
> +++ b/StartupFiles/zshrc
> @@ -79,7 +79,7 @@ export HELPDIR=/usr/share/zsh/$ZSH_VERSION/help  #
> directory for run-help functi
>  unalias run-help && autoload -Uz run-help
>
>  MAILCHECK=300
> -HISTSIZE=200
> +HISTSIZE=1000
>  DIRSTACKSIZE=20
>
>  # Watch for my friends
> diff --git a/configure.ac b/configure.ac
> index 890ef8dd2..6ca5c9189 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -3213,7 +3213,7 @@ AH_TOP([/***** begin user configuration section
> *****/
>  #define USE_SUSPENDED 1
>
>  /* The default history buffer size in lines */
> -#define DEFAULT_HISTSIZE 30
> +#define DEFAULT_HISTSIZE 1000
>
>  /* The default editor for the fc builtin */
>  #define DEFAULT_FCEDIT "vi"
> --
> 2.37.2.351.g9bf691b78c.dirty

No opinion either way on the default size.

-- 
Mikael Magnusson


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

* Re: [PATCH v2 1/1] Increase default HISTSIZE to 1000
  2022-09-06 20:15   ` Mikael Magnusson
@ 2022-09-07  0:08     ` Felipe Contreras
  0 siblings, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2022-09-07  0:08 UTC (permalink / raw)
  To: Mikael Magnusson
  Cc: zsh-workers, Peter Stephenson, Daniel Shahaf, Bart Schaefer

On Tue, Sep 6, 2022 at 3:15 PM Mikael Magnusson <mikachu@gmail.com> wrote:
> On 9/6/22, Felipe Contreras <felipe.contreras@gmail.com> wrote:

> > If the default is sensible then it's not necessary for the user to
> > change it.
> >
> > Moreover, the FAQ is wrong: it says it's necessary to set HISTSIZE for
> > the history to saved, but it isn't. HISTSIZE by default is 30 and that's
> > enough to save the history, although not very useful. Therefore only
> > *two* variables need to be set.
> >
> > This is even more clear after we remove HISTSIZE from the example, but
> > then the text "The simplest possibility is to set it to the same as
> > tt($HISTSIZE) as above" becomes problematic as the value of HISTSIZE is
> > not readily available.
> >
> > The user doesn't need to know the value of HISTSIZE though, she can
> > simply use $HISTSIZE instead.
> >
> > This has the advantage that if HISTSIZE is increased again in the future
> > (as it probably should because most modern computers can easily afford
> > orders of magnitude more), nobody needs to worry about SAVEHIST (neither
> > in the FAQ, zsh-newuser-install, or existing zshrc files).
> >
> > Also, semantically makes more sense and carries less cognitive load.
> >
> > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > ---
> >  Etc/FAQ.yo                            | 17 +++++++----------
> >  Functions/Newuser/zsh-newuser-install |  3 +--
> >  StartupFiles/zshrc                    |  2 +-
> >  configure.ac                          |  2 +-
> >  4 files changed, 10 insertions(+), 14 deletions(-)
> >
> > diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> > index 8c795685a..4c058c363 100644
> > --- a/Etc/FAQ.yo
> > +++ b/Etc/FAQ.yo
> > @@ -1626,19 +1626,16 @@ work?)
> >  sect(Why is my history not being saved?)
> >  label(321)
> >
> > -  In zsh, you need to set three variables to make sure your history is
> > +  In zsh, you need to set two variables to make sure your history is
> >    written out when the shell exits.  For example,
> >    verb(
> > -    HISTSIZE=200
> >      HISTFILE=~/.zsh_history
> > -    SAVEHIST=200
> > -  )
> > -  tt($HISTSIZE) tells the shell how many lines to keep internally,
> > -  tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
> > -  the easiest one to forget, tells it how many to write out.  The
> > -  simplest possibility is to set it to the same as tt($HISTSIZE) as
> > -  above.  There are also various options affecting history; see the
> > -  manual.
> > +    SAVEHIST=$HISTSIZE
> > +  )
> > +  tt($HISTFILE) tells the shell where to write the history, and
> > tt($SAVEHIST)
> > +  tells it how many lines to write out.  The simplest possibility is to set
> > it
> > +  to the same as tt($HISTSIZE) as above.  There are also various options
> > +  affecting history; see the manual.
>
> NAK on the above hunk from me, making the FAQ less informative is not a goal.

The goal of the FAQ is to answer common questions, and the goal of
this entry is to answer the question "Why is my history not being
saved?", not inform the user about history. That's already done in the
user's guide Setting up history [1], and in the manual's roadmap
Interactive Use [2]. If you want to inform the user about history, a
link should be provided to either of those, not attempt to repeat the
same information except in a poorer way.

To answer the question at hand "Why is my history not being saved?"
it's *not necessary* to explain HISTSIZE (yet again), and it's not
desirable to answer something the user did not ask.

> >  sect(How do I get a variable's value to be evaluated as another variable?)
> >
> > diff --git a/Functions/Newuser/zsh-newuser-install
> > b/Functions/Newuser/zsh-newuser-install
> > index 9e911d07c..46b1639c5 100644
> > --- a/Functions/Newuser/zsh-newuser-install
> > +++ b/Functions/Newuser/zsh-newuser-install
> > @@ -790,9 +790,8 @@ ${(F)unparsed}
> >
> >  __zni_history_config() {
> >    __zni_apply_defaults -p \
> > -    HISTSIZE 1000 "Number of lines of history kept within the shell." \
> >      HISTFILE $zdmsg/.histfile "File where history is saved." \
> > -    SAVEHIST 1000 "Number of lines of history to save to \$HISTFILE."
> > +    SAVEHIST \$HISTSIZE "Number of lines of history to save to
> > \$HISTFILE."
> >
> >    if __zni_display_and_edit "History configuration"; then
> >      install_state[history]="Unsaved changes"
>
> Ditto here for the same reason.

The reason "making the FAQ less informative is not a goal" doesn't
apply here. The purpose of the zsh-newuser-install script is not to
provide the user with information, again, that is already done in the
user's guide and the manual. Neither is it to inform the user of all
the history options in the manual [3] that the user might want to set,
like EXTENDED_HISTORY, HIST_IGNORE_SPACE, INC_APPEND_HISTORY, or
SHARE_HISTORY.

The purpose of the script as it's clearly stated when you start it is
"help you with a few settings that should make your use of the shell
easier", not inform the user of all the settings, or even typical
settings.

[1] https://zsh.sourceforge.io/Guide/zshguide02.html#l17
[2] https://zsh.sourceforge.io/Doc/Release/Roadmap.html#Interactive-Use
[3] https://zsh.sourceforge.io/Doc/Release/Options.html#Description-of-Options

-- 
Felipe Contreras


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

end of thread, other threads:[~2022-09-07  0:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 19:50 [PATCH v2 0/1] Useful default of HISTSIZE Felipe Contreras
2022-09-06 19:50 ` [PATCH v2 1/1] Increase default HISTSIZE to 1000 Felipe Contreras
2022-09-06 20:15   ` Mikael Magnusson
2022-09-07  0:08     ` Felipe Contreras

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).