Announcement

Collapse
No announcement yet.

via a script - change Scrollback

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    via a script - change Scrollback


    1000 Lines = current Adjust Scrollback - Konsole

    Question:
    Inside a Bash script, how to change Scrollback from
    1000 Lines to
    9999 Lines? via a script, not manually.

    What is the script command?



    using
    Kubuntu 22.04
    (Jammy Jellyfish)


    konsole 21.12.3

    Qt: 5.15.3
    KDE Frameworks: 5.92.0
    kf5-config: 1.0​

    --

    #2
    I don't think you can change it on-the-fly. IME, a change to the console requires a reloading of the console - basically logging out of it and re-opening it. Which seems unlikely that would do want you want.

    I haven't tried this, but it seems you can reload your profile without logging out with this command:

    . ~/.profile

    IDK if you could set HISTFILESIZE there and reload it it might work. From the man page:

    HISTFILESIZE
    The maximum number of lines contained in the history file. When this variable is assigned a value, the history file is truncated, if necessary, to
    contain no more than that number of lines by removing the oldest entries. The history file is also truncated to this size after writing it when a
    shell exits. If the value is 0, the history file is truncated to zero size. Non-numeric values and numeric values less than zero inhibit truncation.
    The shell sets the default value to the value of HISTSIZE after reading any startup files.

    If you better explained what exactly you're trying to accomplish, someone might have a suggestion.

    Points to ponder:
    My HISTFILESIZE is set in ~/.bashrc at 20000. ~/.bash_history currently occupies less than a half-meg (before compression). Assuming you wanted 9999 and the storage was roughly equal - 250k. Not really that big of a file in the scheme of things.

    If you want to expand, then trim the history file for some reason, you could set it at 9999, then truncate it when exiting the terminal via a command in ~/.bash_logout.

    It's hard to guess what you want without explanation as to why or actual details.

    Please Read Me

    Comment


      #3
      oshunluvr has advised about the bash history, but I think the OP has asked about the konsole "scrollback", in konsole Settings->Edit Current Profile...->Scrolling->Scrollback.

      The settings for each profile stored are in ~/.local/share/konsole, and you can change the scrollback size there. For example, for a profile named "white",
      Code:
       sed -i 's/HistorySize=[0-9]*/HistorySize=2200/' ~/.local/share/konsole/white.profile
      (If the konsole has no or unlimited scrollback, that won't work, without any indication. "HistoryMode" has to be set to 1, then the HistorySize line added to the [Scrolling] section.)

      This won't affect a running konsole using that profile. But that can be done with qdbus!
      Code:
      qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION org.kde.konsole.Session.setHistorySize 9999
      (It's a long time since I've gone down the qdbus rabbit-hole and found something that works.)
      Last edited by jlittle; Sep 14, 2022, 08:11 PM. Reason: typo
      Regards, John Little

      Comment


      • oshunluvr
        oshunluvr commented
        Editing a comment
        Silly me. I thought they were the same thing...

      #4
      Code:
      qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION org.kde.konsole.Session.setHistorySize 9999
      If Terminal scrollback is set to Unlimited,
      then above code works as a Terminal command.

      If Terminal scrollback is set to Fixed, then above code does not work.
      scrollback remains at 1000 Lines not 9999 Lines.

      background:
      Ctrl-Alt-T = Terminal / right click / adjust scrollback / Fixed size 1000 Lines

      or

      If task is too difficult to do in a script
      then how to manually and permanently change scrollback to
      99123 Lines?


      because the scrollback windows says:
      Any adjustments are only temporary to this session.

      --

      Comment


        #5
        Originally posted by joseph22 View Post
        Code:
        qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION org.kde.konsole.Session.setHistorySize 9999
        If Terminal scrollback is set to Fixed, then above code does not work.
        scrollback remains at 1000 Lines not 9999 Lines.
        The setting as seen in edit profile screen does not change, but the actual amount of scrollback changes for me. If I fix the scrollback to 1000 in the settings, restart the console, then run seq 2000, then scroll all the way back using the scrollbar thumb, the bottom line is 1001. If I then run the qdbus command to set the size to 100, the thumb increases in size greatly and if I use it to scroll all the way back the bottom line is 1903. If I use the qdbus command to set it to 0, the konsole doesn't scroll at all. The profile setting is unchanged, and will be used for new windows with that profile; to change that edit the .profile file.
        Originally posted by joseph22 View Post
        how to manually and permanently change scrollback...
        Well, edit the .profile file. I copy those between systems, and back them up with (lots of) other "dotfiles".
        Regards, John Little

        Comment


          #6

          Originally posted by jlittle View Post
          Well, edit the .profile file. I copy those between systems, and back them up with (lots of) other "dotfiles".
          Hello jlittle
          What is the command inside .profile?

          How to change Scrollback from
          1000 Lines to
          9999 Lines?​



          Found file at

          /home/X/.profile

          above file says :



          # ~/.profile: executed by the command interpreter for login shells.
          # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
          # exists.
          # see /usr/share/doc/bash/examples/startup-files for examples.
          # the files are located in the bash-doc package.

          # the default umask is set in /etc/profile; for setting the umask
          # for ssh logins, install and configure the libpam-umask package.
          #umask 022

          # if running bash
          if [ -n "$BASH_VERSION" ]; then
          # include .bashrc if it exists
          if [ -f "$HOME/.bashrc" ]; then
          . "$HOME/.bashrc"
          fi
          fi

          # set PATH so it includes user's private bin if it exists
          if [ -d "$HOME/bin" ] ; then
          PATH="$HOME/bin:$PATH"
          fi

          # set PATH so it includes user's private bin if it exists
          if [ -d "$HOME/.local/bin" ] ; then
          PATH="$HOME/.local/bin:$PATH"
          fi

          Comment


            #7
            Originally posted by joseph22 View Post
            What is the command inside .profile?
            The konsole settings have nothing to do with the ".profile" in your home directory.

            I'm sorry, because you asked for "bash script" I assumed you'd understand "The settings for each profile stored are in [console]~/.local/share/konsole[/console], and using an example for a konsole profile file called "white" with a command that referred to [console]~/.local/share/konsole/white.profile[/console] would be enough.

            The sed command I gave would fit naturally in a bash script, though it is for a particular profile name. One could remove that with
            Code:
            konsole_profile=$(qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION org.kde.konsole.Session.profile)
            sed -i 's/HistorySize=[0-9]*/HistorySize=2200/' ~/.local/share/konsole/$konsole_profile.profile
            but I suspect I'm going too far.
            Regards, John Little

            Comment


              #8
              Originally posted by jlittle View Post
              I assumed you'd understand
              i do not understand.


              If you have time then clarify.

              Is code for a bash script?
              an on the fly code that can change total Lines with each script
              or
              Is code for a permanent setting?

              What code goes to which file?
              using Kubuntu 22.04

              etc.


              The problem:
              1000 Lines fixed is system default and is too small

              changing 1000 Lines to 9999 Lines manually, is only temporary per session
              changing 1000 Lines to unlimited Lines manually, is only temporary per session
              changing 1000 Lines to unlimited is not desired
              changing 1000 Lines to 100 million Lines or 99,999,999 is desired versus unlimited



              Question is:
              How to change Scrollback from
              1000 Lines to
              9999 Lines?​​

              How to change Scrollback via a script? was the first question.
              How to change Scrollback via a permanent setting is Ok too.

              --

              Comment


                #9
                Originally posted by joseph22 View Post
                How to change Scrollback via a permanent setting is Ok too.
                That's easy enough. Launch Kate and open the file .bashrc (the period is part of the file name). Change the value for HISTSIZE and HISTFILESIZE as desired. HISTFILESIZE is the maximum number of lines contained in the history file. HISTSIZE is the number of commands to remember in the command history.

                You can read about this by searching for man bash in your browser.
                Windows no longer obstructs my view.
                Using Kubuntu Linux since March 23, 2007.
                "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                Comment


                  #10
                  Originally posted by Snowhog View Post
                  That's easy enough.
                  Launch Kate and open the file
                  .bashrc
                  (the period is part of the file name).
                  Change the value for HISTSIZE and HISTFILESIZE as desired.
                  HISTFILESIZE is the maximum number of lines contained in the history file.
                  HISTSIZE is the number of commands to remember in the command history.
                  You can read about this by searching for man bash in your browser.

                  Code:
                  kate ~/.bashrc
                  or said differently
                  Code:
                  kate /home/X/.bashrc


                  changed to
                  HISTSIZE=9999
                  HISTFILESIZE=9999999



                  Closed all windows
                  Restart computer
                  Opened Terminal

                  Code:
                  seq 11041
                  result:
                  11041 bottom Line
                  10001 top Line, Ctrl-Shift-Home
                  ------------------------------------------
                  _1040 total displayed Lines


                  but total displayed Lines is too small.
                  How come?

                  Comment


                    #11
                    Originally posted by joseph22 View Post
                    but total displayed Lines is too small.
                    How come?
                    Read up about this by searching for man bash in your browser.
                    Windows no longer obstructs my view.
                    Using Kubuntu Linux since March 23, 2007.
                    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                    Comment


                      #12
                      Originally posted by Snowhog View Post
                      Read up about this by searching for man bash in your browser.

                      man bash excerpt:


                      HISTFILE
                      The name of the file in which command history is saved (see HISTORY below). The default value is ~/.bash_history.
                      If unset, the command history is not saved when a shell exits.

                      HISTFILESIZE
                      The maximum number of lines contained in the history file. When this variable is assigned a value, the history file
                      is truncated, if necessary, to contain no more than that number of lines by removing the oldest entries. The history
                      file is also truncated to this size after writing it when a shell exits. If the value is 0, the history file is truncated to zero size. Non-numeric values and numeric values less than zero inhibit truncation. The shell sets the default value to the value of HISTSIZE after reading any startup files.

                      HISTIGNORE
                      A colon-separated list of patterns used to decide which command lines should be saved on the history list. Each pat‐
                      tern is anchored at the beginning of the line and must match the complete line (no implicit `*' is appended). Each
                      pattern is tested against the line after the checks specified by HISTCONTROL are applied. In addition to the normal
                      shell pattern matching characters, `&' matches the previous history line. `&' may be escaped using a backslash; the
                      backslash is removed before attempting a match. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of HISTIGNORE. The pattern matching honors the setting of the extglob shell option.

                      HISTSIZE
                      The number of commands to remember in the command history (see HISTORY below). If the value is 0, commands are not saved in the history list. Numeric values less than zero result in every command being saved on the history list
                      (there is no limit). The shell sets the default value to 500 after reading any startup files.

                      HISTTIMEFORMAT
                      If this variable is set and not null, its value is used as a format string for strftime(3) to print the time stamp
                      associated with each history entry displayed by the history builtin. If this variable is set, time stamps are writ‐
                      ten to the history file so they may be preserved across shell sessions. This uses the history comment character to
                      distinguish timestamps from other history lines.

                      man bash has 4419 lines


                      Question:
                      How to permanently change Scrollback from
                      1000 Lines to
                      9999 Lines? or more

                      Comment

                      Working...
                      X