Giter Club home page Giter Club logo

Comments (2)

marlonrichert avatar marlonrichert commented on July 4, 2024 2

That's already possible in Zsh natively. You have three options for this, all of which can be combined:

  • Add setopt HIST_IGNORE_SPACE to your .zshrc file. Then, if you insert at least one space at the very beginning of a command line, it will not be saved to history, although it is still saved to local history in memory.
  • Add HISTORY_IGNORE=<glob pattern to your .zshrc file. Then, any command line that matches that pattern will not be saved to history.
  • Add a history hook function to your .zshrc file:
    autoload -Uz
    <function>() {
      <logic>
    }
    add-zsh-hook zshaddhistory <function>
    Then, whenever you submit a command line, before it is executed, it will be passed to this function. If the function returns 1, it will not be saved. If it returns 2, it will be saved to local history in memory, but will not be saved to the $HISTFILE. Returning 0 will save the command line to history, unless prevented by one of the other two options.

from zsh-hist.

martin-braun avatar martin-braun commented on July 4, 2024

@marlonrichert Thank you for the detailed explanation, it makes sense to do it this way. Very useful.

from zsh-hist.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.